diff options
Diffstat (limited to 'src/views/_sila/Fans/Dynamic')
-rw-r--r-- | src/views/_sila/Fans/Dynamic/FanSpeedCpu.vue | 117 | ||||
-rw-r--r-- | src/views/_sila/Fans/Dynamic/FanSpeedSystem.vue | 131 |
2 files changed, 186 insertions, 62 deletions
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 @@ <img src="@/assets/images/_sila/collapsed/fan.svg" /> </template> <page-section> - <!-- <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.number="warning" - type="number" - :min="0" - :max="shutdown" + <b-form novalidate> + <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.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" md="6" xl="3" class="pt-4"> + <b-form-group :label="$t('pageFans.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" md="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" md="6" xl="3" class="pt-4"> - <b-form-group :label="$t('pageFans.labels.shutdown')"> - <b-form-input - v-model.number="shutdown" - :min="warning" - :max="10000" - type="number" - ></b-form-input> - </b-form-group> - </b-col> - <b-col xs="12" md="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="fans" :colors="colors" @@ -93,17 +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, BVToastMixin], + mixins: [ + DataFormatterMixin, + LoadingBarMixin, + TableFilterMixin, + BVToastMixin, + VuelidateMixin, + ], props: { timeScale: { type: String, @@ -112,6 +149,7 @@ export default { }, data() { return { + loading, warning: null, critical: null, isBusy: true, @@ -152,10 +190,24 @@ 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() { const allArr = getItems(this.filteredSensors); @@ -245,15 +297,20 @@ 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 '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 @@ <img src="@/assets/images/_sila/collapsed/fan.svg" /> </template> <page-section> - <!-- <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" - type="number" - :min="0" - :max="shutdown" + <b-form novalidate> + <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.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" md="6" xl="3" class="pt-4"> + <b-form-group :label="$t('pageFans.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" md="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" md="6" xl="3" class="pt-4"> - <b-form-group :label="$t('pageFans.labels.shutdown')"> - <b-form-input - v-model="shutdown" - :min="warning" - :max="10000" - type="number" - ></b-form-input> - </b-form-group> - </b-col> - <b-col xs="12" md="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="fans" :colors="colors" :time-scale="timeScale" :data="filteredForChart" - :warning="warning" - :critical="critical" + :warning="warningLimit" + :critical="criticalLimit" :max="maxLimit" ></chart> @@ -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': |