diff options
author | Vitalii Lysak <v.lysak@dunice.net> | 2022-08-25 12:16:17 +0300 |
---|---|---|
committer | Vitalii Lysak <v.lysak@dunice.net> | 2022-08-25 12:16:17 +0300 |
commit | 0847eaf4cc4b050fc6f297940013a3e7e4c1cb81 (patch) | |
tree | d30763106339ce9f0b2c1ea3d7b594915257755a | |
parent | dc974638f3ea285f8da00a1a084d08ce3ede8949 (diff) | |
download | webui-vue-0847eaf4cc4b050fc6f297940013a3e7e4c1cb81.tar.xz |
SILABMC-256: add limits for Voltage
-rw-r--r-- | src/components/_sila/Global/Chart.vue | 117 | ||||
-rw-r--r-- | src/store/modules/HardwareStatus/PowerSupplyStore.js | 42 | ||||
-rw-r--r-- | src/views/_sila/Power/Dynamic/VoltInput.vue | 124 | ||||
-rw-r--r-- | 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 @@ <img src="@/assets/images/_sila/collapsed/voltage.svg" /> </template> <page-section> - <!-- <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.number="warning" - type="number" - :min="0" - :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.critical')"> - <b-form-input - v-model.number="critical" - type="number" - :min="warning" - :max="250" + <b-form novalidate> + <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.number="warning" + :disabled="$store.getters['authentication/role'] === 'ReadOnly'" + type="number" + :state="getValidationState($v.warning)" + @blur="$v.warning.$touch()" + ></b-form-input> + <b-form-invalid-feedback class="absolute" role="alert"> + <div v-if="!$v.warning.between"> + {{ $t('global.form.invalidValue') }} + </div> + <div v-if="!$v.warning.required"> + {{ $t('global.form.fieldRequired') }} + </div> + </b-form-invalid-feedback> + </b-form-group> + </b-col> + <b-col xs="12" sm="6" xl="3" class="pt-4"> + <b-form-group :label="$t('pagePowerSup.labels.critical')"> + <b-form-input + v-model.number="critical" + :disabled="$store.getters['authentication/role'] === 'ReadOnly'" + type="number" + :state="getValidationState($v.critical)" + @blur="$v.critical.$touch()" + > + </b-form-input> + <b-form-invalid-feedback class="absolute" role="alert"> + <div v-if="!$v.critical.between"> + {{ $t('global.form.invalidValue') }} + </div> + <div v-if="!$v.critical.required"> + {{ $t('global.form.fieldRequired') }} + </div> + </b-form-invalid-feedback> + </b-form-group> + </b-col> + <b-col xs="12" sm="6" xl="3" class="pt-4"> + <b-button + variant="primary" + style="height: 35px" + :disabled=" + loading || $store.getters['authentication/role'] === 'ReadOnly' + " + @click="saveLimit" > - </b-form-input> - </b-form-group> - </b-col> - <b-col xs="12" sm="6" xl="3" class="pt-4"> - <b-button variant="primary" style="height: 35px" @click="saveLimit"> - {{ $t('global.action.save') }} - </b-button> - </b-col> - </b-row>--> + {{ $t('global.action.save') }} + </b-button> + </b-col> + </b-row> + </b-form> <chart type="voltage-input" :time-scale="timeScale" @@ -43,6 +70,7 @@ :colors="colors" :warning="warningLimit" :critical="criticalLimit" + :max="maxLimit" ></chart> <b-table responsive="md" @@ -86,17 +114,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 { psuFilter } from '@/utilities/_sila/psuFilter'; export default { components: { PageSection, Chart, Collapse }, - mixins: [DataFormatterMixin, LoadingBarMixin, TableFilterMixin, BVToastMixin], + mixins: [ + DataFormatterMixin, + LoadingBarMixin, + TableFilterMixin, + BVToastMixin, + VuelidateMixin, + ], props: { timeScale: { type: String, @@ -105,6 +143,7 @@ export default { }, data() { return { + loading, warning: null, critical: null, isBusy: true, @@ -137,6 +176,20 @@ export default { ], }; }, + + validations() { + return { + warning: { + required, + between: between(1, this.critical), + }, + critical: { + required, + between: between(this.warning, this.maxLimit), + }, + }; + }, + computed: { groups() { return getGroups(this.filteredItems); @@ -147,6 +200,10 @@ export default { }, limits() { + console.log( + 'limits input!!!', + this.$store.getters['powerSupply/limitsVol'] + ); return this.$store.getters['powerSupply/limitsVol']; }, @@ -167,6 +224,12 @@ export default { })?.UpperThresholdCritical; }, + maxLimit() { + return this.limits.find((limit) => { + 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 @@ <img src="@/assets/images/_sila/collapsed/voltage.svg" /> </template> <page-section> - <!-- <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" - type="number" - :min="0" - :max="shutdown" - ></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-input - v-model="shutdown" - type="number" - :min="warning" - :max="100" + <b-form novalidate> + <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.number="warning" + :disabled="$store.getters['authentication/role'] === 'ReadOnly'" + type="number" + :state="getValidationState($v.warning)" + @blur="$v.warning.$touch()" + ></b-form-input> + <b-form-invalid-feedback class="absolute" role="alert"> + <div v-if="!$v.warning.between"> + {{ $t('global.form.invalidValue') }} + </div> + <div v-if="!$v.warning.required"> + {{ $t('global.form.fieldRequired') }} + </div> + </b-form-invalid-feedback> + </b-form-group> + </b-col> + <b-col xs="12" sm="6" xl="3" class="pt-4"> + <b-form-group :label="$t('pagePowerSup.labels.critical')"> + <b-form-input + v-model.number="critical" + :disabled="$store.getters['authentication/role'] === 'ReadOnly'" + type="number" + :state="getValidationState($v.critical)" + @blur="$v.critical.$touch()" + > + </b-form-input> + <b-form-invalid-feedback class="absolute" role="alert"> + <div v-if="!$v.critical.between"> + {{ $t('global.form.invalidValue') }} + </div> + <div v-if="!$v.critical.required"> + {{ $t('global.form.fieldRequired') }} + </div> + </b-form-invalid-feedback> + </b-form-group> + </b-col> + <b-col xs="12" sm="6" xl="3" class="pt-4"> + <b-button + variant="primary" + style="height: 35px" + :disabled=" + loading || $store.getters['authentication/role'] === 'ReadOnly' + " + @click="saveLimit" > - </b-form-input> - </b-form-group> - </b-col> - <b-col xs="12" sm="6" xl="3" class="pt-4"> - <b-button variant="primary" style="height: 35px"> - {{ $t('global.action.save') }} - </b-button> - </b-col> - </b-row> --> + {{ $t('global.action.save') }} + </b-button> + </b-col> + </b-row> + </b-form> <chart type="voltage-output" :time-scale="timeScale" :data="filteredItems" :colors="colors" - :warning="+warning" - :shutdown="+shutdown" + :warning="warningLimit" + :critical="criticalLimit" + :max="maxLimit" ></chart> <b-table responsive="md" @@ -86,16 +114,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 VuelidateMixin from '@/components/_sila/Mixins/VuelidateMixin.js'; import Collapse from '@/components/_sila/Global/Collapse'; -import { getItems } from '@/utilities/_sila/metricProperties'; +import { getGroups, getItems } from '@/utilities/_sila/metricProperties'; +import { between, required } from 'vuelidate/lib/validators'; import { psuFilter } from '@/utilities/_sila/psuFilter'; +import BVToastMixin from '@/components/_sila/Mixins/BVToastMixin'; export default { components: { PageSection, Chart, Collapse }, - mixins: [DataFormatterMixin, LoadingBarMixin, TableFilterMixin], + mixins: [ + DataFormatterMixin, + LoadingBarMixin, + TableFilterMixin, + BVToastMixin, + VuelidateMixin, + ], props: { timeScale: { type: String, @@ -104,8 +143,9 @@ export default { }, data() { return { - warning: Infinity, - shutdown: Infinity, + loading, + warning: null, + critical: null, isBusy: true, fields: [ { @@ -137,11 +177,59 @@ export default { }; }, + validations() { + return { + warning: { + required, + between: between(1, this.critical), + }, + critical: { + required, + between: between(this.warning, this.maxLimit), + }, + }; + }, + computed: { + groups() { + return getGroups(this.filteredItems); + }, + items() { return getItems(this.filteredItems); }, + limits() { + console.log( + 'limits!!!****', + this.$store.getters['powerSupply/limitsVol'] + ); + 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; + }, + + 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(); + }); }); }, }, |