diff options
-rw-r--r-- | src/components/_sila/Global/Chart.vue | 206 | ||||
-rw-r--r-- | src/locales/en-US.json | 6 | ||||
-rw-r--r-- | src/locales/ru-RU.json | 6 | ||||
-rw-r--r-- | src/store/modules/HardwareStatus/MotherboardStore.js | 24 | ||||
-rw-r--r-- | src/views/_sila/Motherboard/Dynamic/MotherboardTemp.vue | 27 |
5 files changed, 154 insertions, 115 deletions
diff --git a/src/components/_sila/Global/Chart.vue b/src/components/_sila/Global/Chart.vue index ac8fc325..01e54071 100644 --- a/src/components/_sila/Global/Chart.vue +++ b/src/components/_sila/Global/Chart.vue @@ -54,27 +54,6 @@ export default { yMax: null, minTickInterval: null, plotBands: null, - plotLines: [ - { - color: '#E11717', - dashStyle: 'solid', - value: this.warning, - zIndex: '1000', - width: 2, - label: { - text: this.$t('chart.thresholdWarning'), - align: 'right', - style: { - fontFamily: 'Inter, sans-serif', - fontSize: '12px', - fontStyle: 'normal', - fontWeight: '400', - lineHeight: '16px', - color: '#0C1C2999', - }, - }, - }, - ], }; }, computed: { @@ -200,20 +179,33 @@ export default { }, }; }, - }, - async created() { - this.setOptions(); - }, + plotLines() { + let plotLines = [ + { + color: '#E11717', + dashStyle: 'solid', + value: this.warning, + zIndex: '1000', + width: 2, + label: { + text: this.$t('chart.thresholdWarning'), + align: 'right', + style: { + fontFamily: 'Inter, sans-serif', + fontSize: '12px', + fontStyle: 'normal', + fontWeight: '400', + lineHeight: '16px', + color: '#0C1C2999', + }, + }, + }, + ]; - methods: { - setOptions() { switch (this.type) { case 'fans': - this.categories = this.setSpeed(10000); - this.minRange = 10000; - this.minTickInterval = 1000; - this.plotLines.push({ + plotLines.push({ color: '#1A3E5B', dashStyle: 'solid', value: this.shutdown, @@ -232,54 +224,8 @@ export default { }, }); break; - case 'memory': - this.categories = this.setCategories(101, 'С°'); - this.yMax = 100; - this.minTickInterval = 25; - this.plotBands = [ - { - color: '#F0AC0C1A', - dashStyle: 'solid', - from: this.notNormal, - to: this.critical, - }, - { - color: '#FF41411A', - dashStyle: 'solid', - from: this.critical, - to: this.warning, - }, - ]; - break; - case 'processors': - this.categories = this.setCategories(101, 'С°'); - this.yMax = 100; - this.minTickInterval = 25; - this.plotBands = [ - { - color: '#F0AC0C1A', - dashStyle: 'solid', - from: this.notNormal, - to: this.critical, - }, - { - color: '#FF41411A', - dashStyle: 'solid', - from: this.critical, - to: this.warning, - }, - ]; - break; - case 'motherboard': - this.categories = this.setCategories(101, 'С°'); - this.yMax = 100; - this.minTickInterval = 25; - break; case 'power': - this.categories = this.setCategories(101, 'Вт'); - this.yMax = 100; - this.minTickInterval = 25; - this.plotLines.push({ + plotLines.push({ color: '#1A3E5B', dashStyle: 'solid', value: this.shutdown, @@ -299,10 +245,7 @@ export default { }); break; case 'voltage-input': - this.categories = this.setCategories(251, 'В'); - this.yMax = 250; - this.minTickInterval = 25; - this.plotLines.push({ + plotLines.push({ color: '#1A3E5B', dashStyle: 'solid', value: this.shutdown, @@ -322,10 +265,7 @@ export default { }); break; case 'voltage-output': - this.categories = this.setCategories(101, 'В'); - this.yMax = 100; - this.minTickInterval = 25; - this.plotLines.push({ + plotLines.push({ color: '#1A3E5B', dashStyle: 'solid', value: this.shutdown, @@ -345,10 +285,7 @@ export default { }); break; case 'current': - this.categories = this.setCategories(11, 'A'); - this.yMax = 10; - this.minTickInterval = 2; - this.plotLines.push({ + plotLines.push({ color: '#1A3E5B', dashStyle: 'solid', value: this.shutdown, @@ -368,10 +305,7 @@ export default { }); break; case 'psu-power': - this.categories = this.setCategories(126, 'Вт'); - this.yMax = 125; - this.minTickInterval = 25; - this.plotLines.push({ + plotLines.push({ color: '#1A3E5B', dashStyle: 'solid', value: this.shutdown, @@ -390,6 +324,90 @@ export default { }, }); } + return plotLines; + }, + }, + + async created() { + this.setOptions(); + }, + + methods: { + setOptions() { + switch (this.type) { + case 'fans': + this.categories = this.setSpeed(10000); + this.minRange = 10000; + this.minTickInterval = 1000; + break; + case 'memory': + this.categories = this.setCategories(101, 'С°'); + this.yMax = 100; + this.minTickInterval = 25; + this.plotBands = [ + { + color: '#F0AC0C1A', + dashStyle: 'solid', + from: this.notNormal, + to: this.critical, + }, + { + color: '#FF41411A', + dashStyle: 'solid', + from: this.critical, + to: this.warning, + }, + ]; + break; + case 'processors': + this.categories = this.setCategories(101, 'С°'); + this.yMax = 100; + this.minTickInterval = 25; + this.plotBands = [ + { + color: '#F0AC0C1A', + dashStyle: 'solid', + from: this.notNormal, + to: this.critical, + }, + { + color: '#FF41411A', + dashStyle: 'solid', + from: this.critical, + to: this.warning, + }, + ]; + break; + case 'motherboard': + this.categories = this.setCategories(101, 'С°'); + this.yMax = 100; + this.minTickInterval = 25; + break; + case 'power': + this.categories = this.setCategories(101, 'Вт'); + this.yMax = 100; + this.minTickInterval = 25; + break; + case 'voltage-input': + this.categories = this.setCategories(251, 'В'); + this.yMax = 250; + this.minTickInterval = 25; + break; + case 'voltage-output': + this.categories = this.setCategories(101, 'В'); + this.yMax = 100; + this.minTickInterval = 25; + break; + case 'current': + this.categories = this.setCategories(11, 'A'); + this.yMax = 10; + this.minTickInterval = 2; + break; + case 'psu-power': + this.categories = this.setCategories(126, 'Вт'); + this.yMax = 125; + this.minTickInterval = 25; + } }, setCategories(count, desc) { const arr = [...new Array(count)].map((i, k) => `${k} ${desc}`); diff --git a/src/locales/en-US.json b/src/locales/en-US.json index 768b499c..2907982b 100644 --- a/src/locales/en-US.json +++ b/src/locales/en-US.json @@ -881,6 +881,9 @@ "temperature": "Temperature indicators", "labels": { "warning": "Meaning of the warning" + }, + "toast": { + "errorLimitUpdate": "Limit update error" } }, "pageProcessors": { @@ -923,6 +926,9 @@ "minDate": "Date of minimum", "maxTemperature": "Maximum, С°", "maxDate": "Date of maximum" + }, + "toast": { + "errorLimitUpdate": "Limit update error" } }, "pagePowerSup": { diff --git a/src/locales/ru-RU.json b/src/locales/ru-RU.json index 13e6fcac..46d75e83 100644 --- a/src/locales/ru-RU.json +++ b/src/locales/ru-RU.json @@ -881,6 +881,9 @@ "temperature": "Показатели температуры", "labels": { "warning": "Значение предупреждения" + }, + "toast": { + "errorLimitUpdate": "Ошибка обновления предела" } }, "pageProcessors": { @@ -923,6 +926,9 @@ "minDate": "Дата минимального", "maxTemperature": "Максимальное, С°", "maxDate": "Дата максимального" + }, + "toast": { + "errorLimitUpdate": "Ошибка обновления предела" } }, "pagePowerSup": { diff --git a/src/store/modules/HardwareStatus/MotherboardStore.js b/src/store/modules/HardwareStatus/MotherboardStore.js index eecd3bc7..e565eaa0 100644 --- a/src/store/modules/HardwareStatus/MotherboardStore.js +++ b/src/store/modules/HardwareStatus/MotherboardStore.js @@ -1,4 +1,5 @@ import api from '@/store/api'; +import i18n from '@/i18n'; const MotherboardStore = { namespaced: true, @@ -24,22 +25,25 @@ const MotherboardStore = { }, }, actions: { - async patchLimits() { - return await api - .get('/redfish/v1/Chassis/SILA_Baseboard/Thermal') - .then(({ data: { Temperatures = [] } }) => - Temperatures.map((temperature) => - api.patch('/redfish/v1/Chassis/SILA_Baseboard/Thermal', { + async patchLimits({ dispatch }, { warning, groups }) { + return Promise.all( + groups.map( + async (group) => + await api.patch('/redfish/v1/Chassis/SILA_Baseboard/Thermal', { Temperatures: [ { - MemberId: temperature.MemberId, - UpperThresholdNonCritical: 7, + MemberId: group, + UpperThresholdNonCritical: warning, }, ], }) - ) ) - .catch((error) => console.log(error)); + ) + .catch((error) => { + console.log(error); + throw new Error(i18n.t('pageMotherboard.toast.errorLimitUpdate')); + }) + .finally(() => dispatch('getLimits')); }, async getLimits({ commit }) { return await api diff --git a/src/views/_sila/Motherboard/Dynamic/MotherboardTemp.vue b/src/views/_sila/Motherboard/Dynamic/MotherboardTemp.vue index 0c482cad..5fac0a89 100644 --- a/src/views/_sila/Motherboard/Dynamic/MotherboardTemp.vue +++ b/src/views/_sila/Motherboard/Dynamic/MotherboardTemp.vue @@ -5,11 +5,11 @@ {{ $t('pageMotherboard.temperature') }} </b-col> - <!-- <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('pageMotherboard.labels.warning')"> <b-form-input - v-model="warning" + v-model.number="warning" type="number" :min="0" :max="100" @@ -17,17 +17,17 @@ </b-form-group> </b-col> <b-col xs="12" sm="6" 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="motherboard" :time-scale="timeScale" :colors="colors" :data="filteredSensors" - :warning="warning" + :warning="warningLimit" ></chart> <b-table responsive="md" @@ -71,12 +71,13 @@ import Chart from '@/components/_sila/Global/Chart'; 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 { getItems, getGroups } from '@/utilities/_sila/metricProperties'; export default { components: { Chart }, - mixins: [DataFormatterMixin, LoadingBarMixin, TableFilterMixin], + mixins: [DataFormatterMixin, LoadingBarMixin, TableFilterMixin, BVToastMixin], props: { timeScale: { type: String, @@ -85,7 +86,7 @@ export default { }, data() { return { - warning: 72, + warning: null, isBusy: true, fields: [ { @@ -133,7 +134,7 @@ export default { return this.$store.getters['motherboard/limits']; }, - limit() { + warningLimit() { return this.limits.find((limit) => { return ( limit?.UpperThresholdNonCritical && @@ -169,14 +170,17 @@ export default { created() { this.loadData(); - // this.saveLimits(); }, methods: { - saveLimits() { + saveLimit() { this.startLoader(); this.$store - .dispatch('motherboard/patchLimits') + .dispatch('motherboard/patchLimits', { + warning: this.warning, + groups: this.groups, + }) + .catch(({ message }) => this.errorToast(message)) .finally(() => this.endLoader()); }, loadData() { @@ -190,6 +194,7 @@ export default { .dispatch('motherboard/getMotherboardDynamic', payload) .finally(() => { this.$store.dispatch('motherboard/getLimits').finally(() => { + this.warning = this.warningLimit; this.endLoader(); this.isBusy = false; }); |