From abd7265f76c5d8f9f8e9512a5e17ed8b58e288a2 Mon Sep 17 00:00:00 2001 From: Vitalii Lysak Date: Wed, 24 Aug 2022 16:31:27 +0300 Subject: SILABMC-256: add limits for Fans --- src/components/_sila/Global/Chart.vue | 2 + src/locales/en-US.json | 4 +- src/locales/ru-RU.json | 2 +- src/store/modules/HardwareStatus/FanStore.js | 36 ++++--- src/views/_sila/Fans/Dynamic/FanSpeedCpu.vue | 117 +++++++++++++++------ src/views/_sila/Fans/Dynamic/FanSpeedSystem.vue | 131 ++++++++++++++++++------ 6 files changed, 212 insertions(+), 80 deletions(-) diff --git a/src/components/_sila/Global/Chart.vue b/src/components/_sila/Global/Chart.vue index 25fa1221..6a3775bb 100644 --- a/src/components/_sila/Global/Chart.vue +++ b/src/components/_sila/Global/Chart.vue @@ -315,6 +315,7 @@ export default { case 'memory': case 'processors': case 'power': + case 'fans': plotBands = [ { color: '#F0AC0C1A', @@ -341,6 +342,7 @@ export default { case 'motherboard': case 'memory': case 'processors': + case 'fans': yMax = this.max; break; case 'power': diff --git a/src/locales/en-US.json b/src/locales/en-US.json index 93dd2188..84fa2168 100644 --- a/src/locales/en-US.json +++ b/src/locales/en-US.json @@ -875,8 +875,8 @@ "motherboard": "Motherboard" }, "labels": { - "warning": "Warning value, rpm", - "shutdown": "Failure value, rpm" + "warning": "Warning, rpm", + "critical": "Critical, rpm" } }, "pageMotherboard": { diff --git a/src/locales/ru-RU.json b/src/locales/ru-RU.json index 148223f3..0b4edc14 100644 --- a/src/locales/ru-RU.json +++ b/src/locales/ru-RU.json @@ -876,7 +876,7 @@ }, "labels": { "warning": "Значение предупреждения, об/мин", - "shutdown": "Значение отказа, об/мин" + "critical": "Критический режим, об/мин" } }, "pageMotherboard": { diff --git a/src/store/modules/HardwareStatus/FanStore.js b/src/store/modules/HardwareStatus/FanStore.js index 9bc84280..8cae4d77 100644 --- a/src/store/modules/HardwareStatus/FanStore.js +++ b/src/store/modules/HardwareStatus/FanStore.js @@ -54,23 +54,29 @@ const FanStore = { }, }, 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, - }, - ], - }) - ) - ) + async patchLimits({ dispatch }, { warning, critical, groups }) { + return await api + .patch('/redfish/v1/Chassis/SILA_Baseboard/Thermal', { + Fans: groups.map((group) => { + return { + MemberId: group, + UpperThresholdNonCritical: warning, + }; + }), + }) + .then(async () => { + return await api.patch('/redfish/v1/Chassis/SILA_Baseboard/Thermal', { + Fans: groups.map((group) => { + return { + MemberId: group, + UpperThresholdCritical: critical, + }; + }), + }); + }) .catch((error) => { console.log(error); - throw new Error(i18n.t('pageMotherboard.toast.errorLimitUpdate')); + throw new Error(i18n.t('pageMemory.toast.errorLimitUpdate')); }) .finally(() => dispatch('getLimits')); }, diff --git a/src/views/_sila/Fans/Dynamic/FanSpeedCpu.vue b/src/views/_sila/Fans/Dynamic/FanSpeedCpu.vue index 07c6618c..c24bc8d7 100644 --- a/src/views/_sila/Fans/Dynamic/FanSpeedCpu.vue +++ b/src/views/_sila/Fans/Dynamic/FanSpeedCpu.vue @@ -8,34 +8,61 @@ - + {{ $t('global.action.save') }} + + + + this.errorToast(message)) .finally(() => this.endLoader()); }, + getPwmByCpu(cpu) { switch (cpu) { case 'CPU1_Fan': diff --git a/src/views/_sila/Fans/Dynamic/FanSpeedSystem.vue b/src/views/_sila/Fans/Dynamic/FanSpeedSystem.vue index bcf0b375..2271ef5c 100644 --- a/src/views/_sila/Fans/Dynamic/FanSpeedSystem.vue +++ b/src/views/_sila/Fans/Dynamic/FanSpeedSystem.vue @@ -8,41 +8,68 @@ - + {{ $t('global.action.save') }} + + + + @@ -93,16 +120,27 @@ import Chart from '@/components/_sila/Global/Chart'; import PageSection from '@/components/Global/PageSection'; import DataFormatterMixin from '@/components/_sila/Mixins/DataFormatterMixin'; -import LoadingBarMixin from '@/components/_sila/Mixins/LoadingBarMixin'; +import LoadingBarMixin, { + loading, +} from '@/components/_sila/Mixins/LoadingBarMixin'; import TableFilterMixin from '@/components/_sila/Mixins/TableFilterMixin'; +import BVToastMixin from '@/components/_sila/Mixins/BVToastMixin'; +import VuelidateMixin from '@/components/_sila/Mixins/VuelidateMixin.js'; import Collapse from '@/components/_sila/Global/Collapse'; import { getGroups, getItems } from '@/utilities/_sila/metricProperties'; +import { between, required } from 'vuelidate/lib/validators'; import { fanFilter } from '@/utilities/_sila/psuFilter'; export default { components: { PageSection, Chart, Collapse }, - mixins: [DataFormatterMixin, LoadingBarMixin, TableFilterMixin], + mixins: [ + DataFormatterMixin, + LoadingBarMixin, + TableFilterMixin, + BVToastMixin, + VuelidateMixin, + ], props: { timeScale: { type: String, @@ -111,6 +149,7 @@ export default { }, data() { return { + loading, warning: null, critical: null, isBusy: true, @@ -151,9 +190,22 @@ export default { }; }, + validations() { + return { + warning: { + required, + between: between(1, this.critical), + }, + critical: { + required, + between: between(this.warning, this.maxLimit), + }, + }; + }, + computed: { groups() { - return getGroups(this.filteredSensors); + return getGroups(this.filteredForChart); }, items() { @@ -244,6 +296,21 @@ export default { }, methods: { + saveLimit() { + this.$v.$touch(); + if (this.$v.$invalid) return; + + this.startLoader(); + this.$store + .dispatch('fan/patchLimits', { + warning: this.warning, + critical: this.critical, + groups: this.groups, + }) + .catch(({ message }) => this.errorToast(message)) + .finally(() => this.endLoader()); + }, + getPwmByCpu(cpu) { switch (cpu) { case 'System_Fan_1': -- cgit v1.2.3