diff options
Diffstat (limited to 'src/views/_sila/Memory/Dynamic/MemoryTemp.vue')
-rw-r--r-- | src/views/_sila/Memory/Dynamic/MemoryTemp.vue | 188 |
1 files changed, 188 insertions, 0 deletions
diff --git a/src/views/_sila/Memory/Dynamic/MemoryTemp.vue b/src/views/_sila/Memory/Dynamic/MemoryTemp.vue new file mode 100644 index 00000000..4c6f2c0a --- /dev/null +++ b/src/views/_sila/Memory/Dynamic/MemoryTemp.vue @@ -0,0 +1,188 @@ +<template> + <div class="custom-divider" style="margin-top: 0"> + <b-button + variant="collapse" + class="d-flex flex-nowrap justify-content-start" + > + <img src="@/assets/images/_sila/collapsed/temperature.svg" /> + {{ $t('pageMemory.temperature') }} + </b-button> + <b-row class="align-items-end p-4"> + <b-col xs="12" md="6" lg="3" class="pt-2"> + <b-form-group :label="$t('pageMemory.labels.notNormal')"> + <b-form-input + v-model="notNormal" + type="number" + :min="0" + :max="55" + ></b-form-input> + </b-form-group> + </b-col> + <b-col xs="12" md="6" lg="3" class="pt-2"> + <b-form-group :label="$t('pageMemory.labels.critical')"> + <b-form-input v-model="critical" type="number" :min="44" :max="72"> + </b-form-input> + </b-form-group> + </b-col> + <b-col xs="12" md="6" lg="3" class="pt-2"> + <b-form-group :label="$t('pageMemory.labels.warning')"> + <b-form-input v-model="warning" type="number" :min="55" :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> + <b-col class="pl-4 pr-4"> + <chart + type="memory" + :colors="colors" + :time-scale="timeScale" + :data="filteredSensors" + :warning="warning" + :not-normal="notNormal" + :critical-start="critical" + ></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> + </b-col> + </div> +</template> +<script> +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 { getItems } from '@/utilities/_sila/metricProperties'; + +export default { + components: { Chart }, + mixins: [DataFormatterMixin, LoadingBarMixin, TableFilterMixin], + props: { + timeScale: { + type: String, + default: 'hour', + }, + }, + data() { + return { + warning: 72, + notNormal: 44, + critical: 55, + fields: [ + { + key: 'name', + label: this.$t('pageMemory.table.name'), + }, + { + key: 'current', + label: this.$t('pageMemory.table.currentTemperature'), + }, + { + key: 'middle', + label: this.$t('pageMemory.table.middleTemperature'), + }, + { + key: 'min', + label: this.$t('pageMemory.table.minTemperature'), + }, + { + key: 'minDate', + label: this.$t('pageMemory.table.minDate'), + }, + { + key: 'max', + label: this.$t('pageMemory.table.maxTemperature'), + }, + { + key: 'maxDate', + label: this.$t('pageMemory.table.maxDate'), + }, + ], + }; + }, + + computed: { + items() { + return getItems(this.filteredSensors); + }, + + allSensors() { + return this.$store.getters['memory/dimms']; + }, + + filteredSensors() { + return this.getFilteredTableData(this.allSensors, this.activeFilters); + }, + + colors() { + return this.$randomColor({ + count: this.items?.length, + hue: 'random', + luminosity: 'random', + }); + }, + }, + + watch: { + timeScale() { + this.loadData(); + }, + }, + + created() { + this.loadData(); + }, + + methods: { + loadData() { + let payload = { lastHour: false }; + if (this.timeScale === 'hour') { + payload = { lastHour: true }; + } + + this.startLoader(); + this.$store.dispatch('memory/getMemoryDynamic', payload).finally(() => { + this.endLoader(); + }); + }, + }, +}; +</script> |