summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitalii Lysak <v.lysak@dunice.net>2022-08-16 18:43:29 +0300
committerVitalii Lysak <v.lysak@dunice.net>2022-08-16 18:43:29 +0300
commit9145a3dfb6608188269a480f7c45a483166d332d (patch)
tree4fd9e840fcc3e4e32de15b79291a7ef62a0c7bfe
parentfe9b637630e8a58a68721d8ade914eff81936a5f (diff)
downloadwebui-vue-9145a3dfb6608188269a480f7c45a483166d332d.tar.xz
SILABMC-256: add fields for fans
-rw-r--r--src/store/modules/HardwareStatus/FanStore.js34
-rw-r--r--src/views/_sila/Fans/Dynamic/FanSpeedCpu.vue65
2 files changed, 86 insertions, 13 deletions
diff --git a/src/store/modules/HardwareStatus/FanStore.js b/src/store/modules/HardwareStatus/FanStore.js
index 26c20254..792c5ad1 100644
--- a/src/store/modules/HardwareStatus/FanStore.js
+++ b/src/store/modules/HardwareStatus/FanStore.js
@@ -1,14 +1,17 @@
import api from '@/store/api';
+import i18n from '@/i18n';
const FanStore = {
namespaced: true,
state: {
fans: [],
fansLastHour: [],
+ limits: [],
},
getters: {
fans: (state) => state.fans,
fansLastHour: (state) => state.fansLastHour,
+ limits: (state) => state.limits,
},
mutations: {
setFanInfo: (state, data) => {
@@ -46,8 +49,39 @@ const FanStore = {
setFansDynamicLastHour: (state, data) => {
state.fansLastHour = data;
},
+ setLimits: (state, data) => {
+ state.limits = data;
+ },
},
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,
+ },
+ ],
+ })
+ )
+ )
+ .catch((error) => {
+ console.log(error);
+ throw new Error(i18n.t('pageMotherboard.toast.errorLimitUpdate'));
+ })
+ .finally(() => dispatch('getLimits'));
+ },
+ async getLimits({ commit }) {
+ return await api
+ .get('/redfish/v1/Chassis/SILA_Baseboard/Thermal')
+ .then(({ data: { Temperatures = [] } }) => {
+ commit('setLimits', Temperatures);
+ })
+ .catch((error) => console.log(error));
+ },
async getFansDynamic({ commit }, { lastHour }) {
let url = null;
if (lastHour) {
diff --git a/src/views/_sila/Fans/Dynamic/FanSpeedCpu.vue b/src/views/_sila/Fans/Dynamic/FanSpeedCpu.vue
index 10f6c9c5..7a3a392d 100644
--- a/src/views/_sila/Fans/Dynamic/FanSpeedCpu.vue
+++ b/src/views/_sila/Fans/Dynamic/FanSpeedCpu.vue
@@ -8,11 +8,11 @@
<img src="@/assets/images/_sila/collapsed/fan.svg" />
</template>
<page-section>
- <!-- <b-row class="align-items-end limit-container">
+ <b-row class="align-items-end limit-container">
<b-col xs="12" md="6" xl="3" class="pt-4">
<b-form-group :label="$t('pageFans.labels.warning')">
<b-form-input
- v-model="warning"
+ v-model.number="warning"
type="number"
:min="0"
:max="shutdown"
@@ -23,7 +23,7 @@
<b-col xs="12" md="6" xl="3" class="pt-4">
<b-form-group :label="$t('pageFans.labels.shutdown')">
<b-form-input
- v-model="shutdown"
+ v-model.number="shutdown"
:min="warning"
:max="10000"
type="number"
@@ -31,18 +31,18 @@
</b-form-group>
</b-col>
<b-col xs="12" md="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="fans"
:colors="colors"
:time-scale="timeScale"
:data="filteredForChart"
- :warning="warning"
- :shutdown="shutdown"
+ :warning="warningLimit"
+ :shutdown="shutdownLimit"
></chart>
<b-table
@@ -94,14 +94,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 { fanFilter } from '@/utilities/_sila/psuFilter';
export default {
components: { PageSection, Chart, Collapse },
- mixins: [DataFormatterMixin, LoadingBarMixin, TableFilterMixin],
+ mixins: [DataFormatterMixin, LoadingBarMixin, TableFilterMixin, BVToastMixin],
props: {
timeScale: {
type: String,
@@ -110,8 +111,8 @@ export default {
},
data() {
return {
- warning: 7500,
- shutdown: 8500,
+ warning: null,
+ shutdown: null,
isBusy: true,
fields: [
{
@@ -151,6 +152,9 @@ export default {
},
computed: {
+ groups() {
+ return getGroups(this.filteredSensors);
+ },
items() {
const allArr = getItems(this.filteredSensors);
@@ -172,6 +176,27 @@ export default {
});
},
+ limits() {
+ return this.$store.getters['fan/limits'];
+ },
+
+ warningLimit() {
+ return this.limits.find((limit) => {
+ return (
+ limit?.UpperThresholdNonCritical &&
+ this.groups.includes(limit.MemberId)
+ );
+ })?.UpperThresholdNonCritical;
+ },
+
+ shutdownLimit() {
+ return this.limits.find((limit) => {
+ return (
+ limit?.UpperThresholdCritical && this.groups.includes(limit.MemberId)
+ );
+ })?.UpperThresholdCritical;
+ },
+
allSensors() {
return this.timeScale === 'hour'
? this.$store.getters['fan/fansLastHour']
@@ -212,6 +237,16 @@ export default {
},
methods: {
+ saveLimit() {
+ this.startLoader();
+ this.$store
+ .dispatch('fan/patchLimits', {
+ warning: this.warning,
+ groups: this.groups,
+ })
+ .catch(({ message }) => this.errorToast(message))
+ .finally(() => this.endLoader());
+ },
getPwmByCpu(cpu) {
switch (cpu) {
case 'CPU1_Fan':
@@ -237,8 +272,12 @@ export default {
this.startLoader();
this.$store.dispatch('fan/getFansDynamic', payload).finally(() => {
- this.endLoader();
- this.isBusy = false;
+ this.$store.dispatch('fan/getLimits').finally(() => {
+ this.warning = this.warningLimit;
+ this.shutdown = this.shutdownLimit;
+ this.endLoader();
+ this.isBusy = false;
+ });
});
},
},