summaryrefslogtreecommitdiff
path: root/src/views/Fans/DynamicInformation/IndicatorsTable.vue
blob: 9cb73863a6099b5a413e033e3b54599d18925e8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<template>
  <page-section class="bootstrap-table__section">
    <span class="bold-12px__caps">
      {{ $t('fansPage.valueIndicators') }}
    </span>
    <b-table
      responsive="md"
      class="bootstrap-fans-table bootstrap-fans-table__stripes"
      :items="filteredSensors"
      :busy="isBusy"
      :fields="fields"
    >
      <template #cell(name)="{ value, index }">
        <div
          class="fans-colors"
          :style="`background-color: ${colors[index]}`"
        ></div>
        <span class="regular-12px tretiatry">
          {{ value }}
        </span>
      </template>
      <template #cell(middleSpeed)="{ value }">
        <span class="regular-12px">
          {{ value.time }}
        </span>
        <span class="regular-12px tretiatry">
          {{ value.date }}
        </span>
      </template>
      <template #cell(minSpeedDate)="{ value }">
        <span class="regular-12px">
          {{ value.time }}
        </span>
        <span class="regular-12px tretiatry">
          {{ value.date }}
        </span>
      </template>
      <template #cell(maxSpeedDate)="{ value }">
        <span class="regular-12px">
          {{ value.time }}
        </span>
        <span class="regular-12px tretiatry">
          {{ value.date }}
        </span>
      </template>
    </b-table>
  </page-section>
</template>

<script>
import PageSection from '@/components/Global/PageSection';
import { colors } from './helpers';

import TableFilterMixin from '@/components/Mixins/TableFilterMixin';
import DataFormatterMixin from '@/components/Mixins/DataFormatterMixin';

export default {
  components: { PageSection },
  mixins: [TableFilterMixin, DataFormatterMixin],
  data() {
    return {
      isBusy: true,
      colors,
      fields: [
        {
          key: 'name',
          label: 'Имя модуля',
          formatter: this.dataFormatter,
          thClass: 'bootstrap-fans-table__th medium-12px',
          tdClass: 'bootstrap-fans-table__td light-12px',
        },
        {
          key: 'currentValue',
          label: 'Текущая',
          formatter: this.dataFormatter,
          thClass: 'bootstrap-fans-table__th medium-12px',
          tdClass: 'bootstrap-fans-table__td light-12px',
        },
        {
          key: 'middleSpeed',
          label: 'Средняя',
          formatter: this.dataFormatter,
          thClass: 'bootstrap-fans-table__th medium-12px',
          tdClass: 'bootstrap-fans-table__td light-12px',
        },
        {
          key: 'lowerCaution',
          label: 'Минимальная',
          formatter: this.dataFormatter,
          thClass: 'bootstrap-fans-table__th medium-12px',
          tdClass: 'bootstrap-fans-table__td light-12px',
        },
        {
          key: 'minSpeedDate',
          label: 'Дата минимальной',
          formatter: this.dataFormatter,
          thClass: 'bootstrap-fans-table__th medium-12px',
          tdClass: 'bootstrap-fans-table__td light-12px',
        },
        {
          key: 'upperCaution',
          label: 'Максимальная',
          formatter: this.dataFormatter,
          thClass: 'bootstrap-fans-table__th medium-12px',
          tdClass: 'bootstrap-fans-table__td light-12px',
        },
        {
          key: 'maxSpeedDate',
          label: 'Дата максимальной',
          formatter: this.dataFormatter,
          thClass: 'bootstrap-fans-table__th medium-12px',
          tdClass: 'bootstrap-fans-table__td light-12px',
        },
      ],
    };
  },

  computed: {
    allSensors() {
      let sensors = this.$store.getters['sensors/fanSensors'];
      if (this.isSensorsExist) {
        sensors.forEach((sensor) => {
          sensor.type = sensor.name.toLowerCase().includes('cpu')
            ? this.$t('tablesDescription.cpu')
            : this.$t('tablesDescription.system');
        });
      }
      return sensors;
    },

    isSensorsExist() {
      return (
        this.$store.getters['sensors/fanSensors'] &&
        this.$store.getters['sensors/fanSensors'].length > 0
      );
    },

    filteredSensors() {
      return this.getFilteredTableData(this.allSensors, this.activeFilters);
    },
  },

  created() {
    this.$store.dispatch('sensors/getFanSensors').finally(() => {
      this.isBusy = false;
    });
  },
};
</script>
<style lang="scss">
.bootstrap-fans-table__th {
  background-color: transparent !important;
  color: $text-primary !important;
  border-top: none !important;
  padding: 10px 5px !important;
  border-bottom: 1px solid $faint-secondary-primary-10;
}

.bootstrap-fans-table__td {
  padding: 5px !important;
  border-top: none !important;
}
</style>

<style lang="scss" scoped>
.fans-colors {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
}
.row {
  align-items: center;
  flex-wrap: nowrap;
  justify-content: flex-end;
}
.medium-12px {
  color: $text-primary !important;
}
</style>