blob: 9e26d90345b7d91ed646eb4f9e7e301492d38fa3 [file] [log] [blame]
Yoshie Muranakab89a53c2020-06-15 13:25:46 -07001<template>
Sandeepa Singh7affc522021-07-06 16:29:10 +05302 <page-section :section-title="$t('pageInventory.fans')">
SurenNeware787635a2020-11-24 22:42:42 +05303 <b-row class="align-items-end">
Yoshie Muranakac069c672020-06-18 14:21:50 -07004 <b-col sm="6" md="5" xl="4">
Dixsie Wolmers9b22b492020-09-07 21:26:06 -05005 <search
Sukanya Pandeyedb8a772020-10-29 11:33:42 +05306 @change-search="onChangeSearchInput"
7 @clear-search="onClearSearchInput"
Dixsie Wolmers9b22b492020-09-07 21:26:06 -05008 />
Yoshie Muranakac069c672020-06-18 14:21:50 -07009 </b-col>
Sukanya Pandey99010962020-07-27 21:44:47 +053010 <b-col sm="6" md="3" xl="2">
11 <table-cell-count
12 :filtered-items-count="filteredRows"
13 :total-number-of-cells="fans.length"
14 ></table-cell-count>
15 </b-col>
Yoshie Muranakac069c672020-06-18 14:21:50 -070016 </b-row>
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070017 <b-table
18 sort-icon-left
19 no-sort-reset
Sukanya Pandeyfde429e2020-09-14 20:48:39 +053020 hover
SurenNeware5e25e282020-07-08 15:57:23 +053021 responsive="md"
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070022 sort-by="health"
SurenNeware307382e2020-07-27 20:45:14 +053023 show-empty
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070024 :items="fans"
25 :fields="fields"
26 :sort-desc="true"
27 :sort-compare="sortCompare"
Yoshie Muranakac069c672020-06-18 14:21:50 -070028 :filter="searchFilter"
SurenNeware307382e2020-07-27 20:45:14 +053029 :empty-text="$t('global.table.emptyMessage')"
SurenNeware156a0e62020-08-28 19:20:03 +053030 :empty-filtered-text="$t('global.table.emptySearchMessage')"
Kenneth Fullbright41057852021-12-27 16:19:37 -060031 :busy="isBusy"
Sukanya Pandey99010962020-07-27 21:44:47 +053032 @filtered="onFiltered"
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070033 >
34 <!-- Expand chevron icon -->
Derick Montague602e98a2020-10-21 16:20:00 -050035 <template #cell(expandRow)="row">
Dixsie Wolmers83133762020-07-15 08:45:19 -050036 <b-button
37 variant="link"
38 data-test-id="hardwareStatus-button-expandFans"
Dixsie Wolmers30f11f82020-11-10 16:07:56 -060039 :title="expandRowLabel"
40 class="btn-icon-only"
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050041 @click="toggleRowDetails(row)"
Dixsie Wolmers83133762020-07-15 08:45:19 -050042 >
Dixsie Wolmers30f11f82020-11-10 16:07:56 -060043 <icon-chevron />
SurenNeware6e2cb972020-12-24 20:58:16 +053044 <span class="sr-only">{{ expandRowLabel }}</span>
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070045 </b-button>
46 </template>
47
48 <!-- Health -->
Derick Montague602e98a2020-10-21 16:20:00 -050049 <template #cell(health)="{ value }">
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070050 <status-icon :status="statusIcon(value)" />
51 {{ value }}
52 </template>
53
Derick Montague602e98a2020-10-21 16:20:00 -050054 <template #row-details="{ item }">
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070055 <b-container fluid>
56 <b-row>
57 <b-col sm="6" xl="4">
58 <dl>
Dixsie Wolmersdd652d72021-05-13 09:08:53 -050059 <!-- Name -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053060 <dt>{{ $t('pageInventory.table.name') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050061 <dd>{{ dataFormatter(item.name) }}</dd>
Dixsie Wolmersdd652d72021-05-13 09:08:53 -050062 </dl>
63 <dl>
64 <!-- Serial number -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053065 <dt>{{ $t('pageInventory.table.serialNumber') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050066 <dd>{{ dataFormatter(item.serialNumber) }}</dd>
Dixsie Wolmersdd652d72021-05-13 09:08:53 -050067 </dl>
68 <dl>
69 <!-- Part number -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053070 <dt>{{ $t('pageInventory.table.partNumber') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050071 <dd>{{ dataFormatter(item.partNumber) }}</dd>
Dixsie Wolmersdd652d72021-05-13 09:08:53 -050072 </dl>
73 <dl>
74 <!-- Fan speed -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053075 <dt>{{ $t('pageInventory.table.fanSpeed') }}:</dt>
Glukhov Mikhaild0b078f2022-12-24 12:16:53 +030076 <dd>
77 {{ dataFormatter(item.speed) }}
78 {{ $t('unit.RPM') }}
79 </dd>
Dixsie Wolmersdd652d72021-05-13 09:08:53 -050080 </dl>
81 </b-col>
82 <b-col sm="6" xl="4">
83 <dl>
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070084 <!-- Status state -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053085 <dt>{{ $t('pageInventory.table.statusState') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050086 <dd>{{ dataFormatter(item.statusState) }}</dd>
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070087 </dl>
Dixsie Wolmersdd652d72021-05-13 09:08:53 -050088 <dl>
89 <!-- Health Rollup state -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053090 <dt>{{ $t('pageInventory.table.statusHealthRollup') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050091 <dd>{{ dataFormatter(item.healthRollup) }}</dd>
Dixsie Wolmersdd652d72021-05-13 09:08:53 -050092 </dl>
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070093 </b-col>
94 </b-row>
95 </b-container>
96 </template>
97 </b-table>
98 </page-section>
99</template>
100
101<script>
102import PageSection from '@/components/Global/PageSection';
103import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
Sukanya Pandey99010962020-07-27 21:44:47 +0530104import TableCellCount from '@/components/Global/TableCellCount';
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700105
106import StatusIcon from '@/components/Global/StatusIcon';
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500107import DataFormatterMixin from '@/components/Mixins/DataFormatterMixin';
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700108import TableSortMixin from '@/components/Mixins/TableSortMixin';
Yoshie Muranakac069c672020-06-18 14:21:50 -0700109import Search from '@/components/Global/Search';
SurenNewareba91c492020-10-27 14:18:54 +0530110import SearchFilterMixin, {
111 searchFilter,
112} from '@/components/Mixins/SearchFilterMixin';
113import TableRowExpandMixin, {
114 expandRowLabel,
115} from '@/components/Mixins/TableRowExpandMixin';
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700116
117export default {
Sukanya Pandey99010962020-07-27 21:44:47 +0530118 components: { IconChevron, PageSection, StatusIcon, Search, TableCellCount },
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500119 mixins: [
120 TableRowExpandMixin,
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500121 DataFormatterMixin,
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500122 TableSortMixin,
Derick Montague602e98a2020-10-21 16:20:00 -0500123 SearchFilterMixin,
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500124 ],
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700125 data() {
126 return {
Kenneth Fullbright41057852021-12-27 16:19:37 -0600127 isBusy: true,
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700128 fields: [
129 {
130 key: 'expandRow',
131 label: '',
132 tdClass: 'table-row-expand',
Derick Montague602e98a2020-10-21 16:20:00 -0500133 sortable: false,
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700134 },
135 {
136 key: 'id',
Sandeepa Singh7affc522021-07-06 16:29:10 +0530137 label: this.$t('pageInventory.table.id'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500138 formatter: this.dataFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500139 sortable: true,
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700140 },
141 {
142 key: 'health',
Sandeepa Singh7affc522021-07-06 16:29:10 +0530143 label: this.$t('pageInventory.table.health'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500144 formatter: this.dataFormatter,
Dixsie Wolmersa04d46f2020-10-22 06:34:56 -0500145 sortable: true,
Derick Montague602e98a2020-10-21 16:20:00 -0500146 tdClass: 'text-nowrap',
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700147 },
148 {
Sandeepa Singh7affc522021-07-06 16:29:10 +0530149 key: 'partNumber',
150 label: this.$t('pageInventory.table.partNumber'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500151 formatter: this.dataFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500152 sortable: true,
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700153 },
154 {
Sandeepa Singh7affc522021-07-06 16:29:10 +0530155 key: 'serialNumber',
156 label: this.$t('pageInventory.table.serialNumber'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500157 formatter: this.dataFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500158 },
Yoshie Muranakac069c672020-06-18 14:21:50 -0700159 ],
SurenNewareba91c492020-10-27 14:18:54 +0530160 searchFilter: searchFilter,
Derick Montague602e98a2020-10-21 16:20:00 -0500161 searchTotalFilteredRows: 0,
SurenNewareba91c492020-10-27 14:18:54 +0530162 expandRowLabel: expandRowLabel,
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700163 };
164 },
165 computed: {
Sukanya Pandey99010962020-07-27 21:44:47 +0530166 filteredRows() {
167 return this.searchFilter
168 ? this.searchTotalFilteredRows
169 : this.fans.length;
170 },
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700171 fans() {
172 return this.$store.getters['fan/fans'];
Derick Montague602e98a2020-10-21 16:20:00 -0500173 },
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700174 },
175 created() {
176 this.$store.dispatch('fan/getFanInfo').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500177 // Emit initial data fetch complete to parent component
Sukanya Pandeyedb8a772020-10-29 11:33:42 +0530178 this.$root.$emit('hardware-status-fans-complete');
Kenneth Fullbright41057852021-12-27 16:19:37 -0600179 this.isBusy = false;
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700180 });
181 },
182 methods: {
183 sortCompare(a, b, key) {
184 if (key === 'health') {
185 return this.sortStatus(a, b, key);
186 }
Yoshie Muranakac069c672020-06-18 14:21:50 -0700187 },
Sukanya Pandey99010962020-07-27 21:44:47 +0530188 onFiltered(filteredItems) {
189 this.searchTotalFilteredRows = filteredItems.length;
Derick Montague602e98a2020-10-21 16:20:00 -0500190 },
191 },
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700192};
193</script>