diff options
author | Vitalii Lysak <v.lysak@dunice.net> | 2022-08-17 10:29:19 +0300 |
---|---|---|
committer | Vitalii Lysak <v.lysak@dunice.net> | 2022-08-17 10:29:19 +0300 |
commit | 362937100773d9180a821e9ee4c1a872c406478a (patch) | |
tree | 62632362ff5acfe8e87d175c78fb60a2cd381e01 | |
parent | 0237b9c60425bbcd2417bf31000cbd74d0112645 (diff) | |
download | webui-vue-362937100773d9180a821e9ee4c1a872c406478a.tar.xz |
SILABMC-256: add fields for power, vol input
-rw-r--r-- | src/store/modules/HardwareStatus/PowerSupplyStore.js | 37 | ||||
-rw-r--r-- | 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 @@ <img src="@/assets/images/_sila/collapsed/voltage.svg" /> </template> <page-section> - <!-- <b-row class="align-items-end limit-container"> + <b-row class="align-items-end limit-container"> <b-col xs="12" sm="6" xl="3" class="pt-4"> <b-form-group :label="$t('pagePowerSup.labels.warning')"> <b-form-input - v-model="warning" + v-model.number="warning" type="number" :min="0" - :max="shutdown" + :max="245" ></b-form-input> </b-form-group> </b-col> <b-col xs="12" sm="6" xl="3" class="pt-4"> - <b-form-group :label="$t('pagePowerSup.labels.shutdown')"> + <b-form-group :label="$t('pagePowerSup.labels.critical')"> <b-form-input - v-model="shutdown" + v-model.number="critical" type="number" :min="warning" :max="250" @@ -31,18 +31,18 @@ </b-form-group> </b-col> <b-col xs="12" sm="6" xl="3" class="pt-4"> - <b-button variant="primary" style="height: 35px"> + <b-button variant="primary" style="height: 35px" @click="saveLimit"> {{ $t('global.action.save') }} </b-button> </b-col> - </b-row> --> + </b-row> <chart type="voltage-input" :time-scale="timeScale" :data="filteredItems" :colors="colors" - :warning="+warning" - :shutdown="+shutdown" + :warning="warningLimit" + :critical="criticalLimit" ></chart> <b-table responsive="md" @@ -88,14 +88,15 @@ import PageSection from '@/components/Global/PageSection'; import DataFormatterMixin from '@/components/_sila/Mixins/DataFormatterMixin'; import LoadingBarMixin from '@/components/_sila/Mixins/LoadingBarMixin'; import TableFilterMixin from '@/components/_sila/Mixins/TableFilterMixin'; +import BVToastMixin from '@/components/_sila/Mixins/BVToastMixin'; import Collapse from '@/components/_sila/Global/Collapse'; -import { getItems } from '@/utilities/_sila/metricProperties'; +import { getGroups, getItems } from '@/utilities/_sila/metricProperties'; import { psuFilter } from '@/utilities/_sila/psuFilter'; export default { components: { PageSection, Chart, Collapse }, - mixins: [DataFormatterMixin, LoadingBarMixin, TableFilterMixin], + mixins: [DataFormatterMixin, LoadingBarMixin, TableFilterMixin, BVToastMixin], props: { timeScale: { type: String, @@ -104,8 +105,8 @@ export default { }, data() { return { - warning: 235, - shutdown: 245, + warning: null, + critical: null, isBusy: true, fields: [ { @@ -137,10 +138,35 @@ export default { }; }, computed: { + groups() { + return getGroups(this.filteredItems); + }, + items() { return getItems(this.filteredItems); }, + limits() { + return this.$store.getters['powerSupply/limitsVol']; + }, + + warningLimit() { + return this.limits.find((limit) => { + 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; + }); }); }, }, |