diff options
author | Maksim Zakharov <m.zakharov@IBS.RU> | 2022-08-05 16:56:18 +0300 |
---|---|---|
committer | Maksim Zakharov <m.zakharov@IBS.RU> | 2022-08-05 16:56:18 +0300 |
commit | c94e39d946b187a39f21307c8cf42e1d1b3c3d8a (patch) | |
tree | 2179868da40b098041c0d26be07441914c0ce312 /src/views/_sila/Power/Dynamic/VoltInput.vue | |
parent | c0f0a956a1def725feb1b821e5507183b435262b (diff) | |
download | webui-vue-c94e39d946b187a39f21307c8cf42e1d1b3c3d8a.tar.xz |
add power supply page
Diffstat (limited to 'src/views/_sila/Power/Dynamic/VoltInput.vue')
-rw-r--r-- | src/views/_sila/Power/Dynamic/VoltInput.vue | 184 |
1 files changed, 184 insertions, 0 deletions
diff --git a/src/views/_sila/Power/Dynamic/VoltInput.vue b/src/views/_sila/Power/Dynamic/VoltInput.vue new file mode 100644 index 00000000..5c39a889 --- /dev/null +++ b/src/views/_sila/Power/Dynamic/VoltInput.vue @@ -0,0 +1,184 @@ +<template> + <collapse + id="collapse_InputVolt" + default-open + :title="$t('pagePowerSup.InputVolt')" + > + <template #image> + <img src="@/assets/images/_sila/collapsed/voltage.svg" /> + </template> + <page-section> + <b-row class="align-items-end p-2"> + <b-col xs="12" md="6" lg="4" class="pt-2"> + <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" md="6" lg="4" class="pt-2"> + <b-form-group :label="$t('pagePowerSup.labels.shutdown')"> + <b-form-input + v-model="shutdown" + type="number" + :min="warning" + :max="250" + > + </b-form-input> + </b-form-group> + </b-col> + <b-col xs="12" md="6" lg="3" class="pt-2"> + <b-button variant="primary" style="height: 35px"> + {{ $t('global.action.save') }} + </b-button> + </b-col> + </b-row> + <chart + type="voltage-input" + :time-scale="timeScale" + :data="filteredItems" + :colors="colors" + :warning="+warning" + :shutdown="+shutdown" + ></chart> + <b-table + responsive="md" + show-empty + table-variant="accessory" + hover + :items="items" + :fields="fields" + :empty-text="$t('global.table.emptyMessage')" + :busy="isBusy" + > + <template #cell(name)="{ value, index }"> + <div + class="item-color" + :style="`background-color: ${colors[index]}`" + ></div> + {{ value }} + </template> + <template #cell(minDate)="{ value }"> + <span style="color: rgb(12, 28, 41)"> + {{ value.time }} + </span> + <span> + {{ value.date }} + </span> + </template> + <template #cell(maxDate)="{ value }"> + <span style="color: rgb(12, 28, 41)"> + {{ value.time }} + </span> + <span> + {{ value.date }} + </span> + </template> + </b-table> + </page-section> + </collapse> +</template> +<script> +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 TableFilterMixin from '@/components/_sila/Mixins/TableFilterMixin'; +import Collapse from '@/components/_sila/Global/Collapse'; + +import { getItems } from '@/utilities/_sila/metricProperties'; +import { psuFilter } from '@/utilities/_sila/psuFilter'; + +export default { + components: { PageSection, Chart, Collapse }, + mixins: [DataFormatterMixin, LoadingBarMixin, TableFilterMixin], + props: { + timeScale: { + type: String, + default: 'hour', + }, + }, + data() { + return { + warning: 235, + shutdown: 245, + isBusy: true, + fields: [ + { + key: 'name', + label: this.$t('pagePowerSup.table.nameModule'), + thStyle: { width: '25%' }, + }, + { + key: 'current', + label: this.$t('pagePowerSup.table.currentVolt'), + }, + { + key: 'min', + label: this.$t('pagePowerSup.table.minVolt'), + }, + { + key: 'minDate', + label: this.$t('pagePowerSup.table.minDate'), + }, + { + key: 'max', + label: this.$t('pagePowerSup.table.maxVolt'), + }, + { + key: 'maxDate', + label: this.$t('pagePowerSup.table.maxDate'), + }, + ], + }; + }, + computed: { + items() { + return getItems(this.filteredItems); + }, + + filteredItems() { + return psuFilter(this.allSensors, 'Input'); + }, + + allSensors() { + return this.timeScale === 'hour' + ? this.$store.getters['powerSupply/psuVoltageLastHour'] + : this.$store.getters['powerSupply/psuVoltage']; + }, + + colors() { + return this.$randomColor({ + count: this.items?.length, + hue: 'random', + luminosity: 'random', + }); + }, + }, + watch: { + timeScale() { + this.loadData(); + }, + }, + created() { + this.loadData(); + }, + methods: { + loadData() { + let payload = { metricsName: 'psu_voltage', lastHour: false }; + if (this.timeScale === 'hour') { + payload.lastHour = true; + } + + this.$store.dispatch('powerSupply/getPsu', payload).finally(() => { + this.$root.$emit('psu-volt'); + this.isBusy = false; + }); + }, + }, +}; +</script> |