diff options
Diffstat (limited to 'src/views/_sila')
-rw-r--r-- | src/views/_sila/Processors/Dynamic/Power.vue | 163 | ||||
-rw-r--r-- | src/views/_sila/Processors/Dynamic/ProcessorsDynamicPage.vue | 16 |
2 files changed, 176 insertions, 3 deletions
diff --git a/src/views/_sila/Processors/Dynamic/Power.vue b/src/views/_sila/Processors/Dynamic/Power.vue new file mode 100644 index 00000000..4f486f6b --- /dev/null +++ b/src/views/_sila/Processors/Dynamic/Power.vue @@ -0,0 +1,163 @@ +<template> + <collapse + id="collapse_power" + :title="$t('pageProcessors.power')" + style="margin-top: 0" + @opened="onOpened" + > + <template #image> + <img src="@/assets/images/_sila/collapsed/power.svg" /> + </template> + <page-section> + <b-row class="align-items-end p-2"> + <b-col xs="12" md="6" lg="3" class="pt-2"> + <b-form-group :label="$t('pageProcessors.labels.warning')"> + <b-form-input + v-model="warning" + type="number" + :min="0" + :max="100" + ></b-form-input> + </b-form-group> + </b-col> + <b-col xs="12" md="6" lg="3" class="pt-2"> + <b-form-group :label="$t('pageProcessors.labels.shutdown')"> + <b-form-input v-model="shutdown" type="number" :min="0" :max="100"> + </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"> + {{ 'Сохранить' }} + </b-button> + </b-col> + </b-row> + <chart + type="processors" + :time-scale="timeScale" + :data="filteredSensors" + :colors="colors" + :warning="warning" + :shutdown="shutdown" + ></chart> + <b-table + v-if="items && items.length > 0" + responsive="md" + show-empty + table-variant="accessory" + hover + :items="items" + :fields="fields" + :empty-text="$t('global.table.emptyMessage')" + > + <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'; + +export default { + components: { PageSection, Chart, Collapse }, + mixins: [DataFormatterMixin, LoadingBarMixin, TableFilterMixin], + data() { + return { + timeScale: 'hour', + warning: 66, + shutdown: 88, + items: [], + fields: [ + { + key: 'name', + label: this.$t('pageProcessors.table.power.name'), + thStyle: { width: '25%' }, + }, + { + key: 'current', + label: this.$t('pageProcessors.table.power.current'), + }, + ], + }; + }, + + computed: { + allSensors() { + return this.$store.getters['processors/cpuPower']; + }, + + filteredSensors() { + return this.getFilteredTableData(this.allSensors, this.activeFilters); + }, + + colors() { + return this.$randomColor({ + count: this.items?.length, + hue: 'random', + luminosity: 'random', + }); + }, + }, + watch: { + filteredSensors(data) { + this.items = getItems(data); + }, + }, + + methods: { + onOpened(state) { + if (state) { + this.loadData(); + } + }, + switchTimeScale(period) { + this.timeScale = period; + this.loadData(); + }, + + loadData() { + let payload = null; + if (this.timeScale === 'hour') { + payload = { lastHour: true }; + } + + this.startLoader(); + this.$store + .dispatch('processors/getCpuPowerDynamic', payload) + .finally(() => { + this.endLoader(); + }); + }, + }, +}; +</script> diff --git a/src/views/_sila/Processors/Dynamic/ProcessorsDynamicPage.vue b/src/views/_sila/Processors/Dynamic/ProcessorsDynamicPage.vue index 45ef53f6..24163bcc 100644 --- a/src/views/_sila/Processors/Dynamic/ProcessorsDynamicPage.vue +++ b/src/views/_sila/Processors/Dynamic/ProcessorsDynamicPage.vue @@ -103,6 +103,8 @@ </b-table> </page-section> </collapse> + + <power></power> </b-container> </template> <script> @@ -117,9 +119,17 @@ import TableFilterMixin from '@/components/_sila/Mixins/TableFilterMixin'; import Collapse from '@/components/_sila/Global/Collapse'; import { getItems } from '@/utilities/_sila/metricProperties'; +import Power from './Power'; export default { - components: { PageTitle, Collapse, PageSection, Chart, TableDatePicker }, + components: { + Power, + PageTitle, + Collapse, + PageSection, + Chart, + TableDatePicker, + }, mixins: [DataFormatterMixin, LoadingBarMixin, TableFilterMixin], data() { return { @@ -215,13 +225,13 @@ export default { if (period === 'hour') { this.startLoader(); this.$store - .dispatch('processors/getProcessorsDynamicHour') + .dispatch('processors/getCpuTempDynamic', { lastHour: true }) .finally(() => { this.endLoader(); }); } else { this.startLoader(); - this.$store.dispatch('processors/getProcessorsDynamic').finally(() => { + this.$store.dispatch('processors/getCpuTempDynamic').finally(() => { this.endLoader(); }); } |