blob: ff568043ddb84cf6e9d99480d9bbc6e7dffd6c43 [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')"
Sukanya Pandey99010962020-07-27 21:44:47 +053031 @filtered="onFiltered"
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070032 >
33 <!-- Expand chevron icon -->
Derick Montague602e98a2020-10-21 16:20:00 -050034 <template #cell(expandRow)="row">
Dixsie Wolmers83133762020-07-15 08:45:19 -050035 <b-button
36 variant="link"
37 data-test-id="hardwareStatus-button-expandFans"
Dixsie Wolmers30f11f82020-11-10 16:07:56 -060038 :title="expandRowLabel"
39 class="btn-icon-only"
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050040 @click="toggleRowDetails(row)"
Dixsie Wolmers83133762020-07-15 08:45:19 -050041 >
Dixsie Wolmers30f11f82020-11-10 16:07:56 -060042 <icon-chevron />
SurenNeware6e2cb972020-12-24 20:58:16 +053043 <span class="sr-only">{{ expandRowLabel }}</span>
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070044 </b-button>
45 </template>
46
47 <!-- Health -->
Derick Montague602e98a2020-10-21 16:20:00 -050048 <template #cell(health)="{ value }">
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070049 <status-icon :status="statusIcon(value)" />
50 {{ value }}
51 </template>
52
Derick Montague602e98a2020-10-21 16:20:00 -050053 <template #row-details="{ item }">
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070054 <b-container fluid>
55 <b-row>
56 <b-col sm="6" xl="4">
57 <dl>
Dixsie Wolmersdd652d72021-05-13 09:08:53 -050058 <!-- Name -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053059 <dt>{{ $t('pageInventory.table.name') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050060 <dd>{{ dataFormatter(item.name) }}</dd>
Dixsie Wolmersdd652d72021-05-13 09:08:53 -050061 </dl>
62 <dl>
63 <!-- Serial number -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053064 <dt>{{ $t('pageInventory.table.serialNumber') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050065 <dd>{{ dataFormatter(item.serialNumber) }}</dd>
Dixsie Wolmersdd652d72021-05-13 09:08:53 -050066 </dl>
67 <dl>
68 <!-- Part number -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053069 <dt>{{ $t('pageInventory.table.partNumber') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050070 <dd>{{ dataFormatter(item.partNumber) }}</dd>
Dixsie Wolmersdd652d72021-05-13 09:08:53 -050071 </dl>
72 <dl>
73 <!-- Fan speed -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053074 <dt>{{ $t('pageInventory.table.fanSpeed') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050075 <dd>{{ dataFormatter(item.speed) }}</dd>
Dixsie Wolmersdd652d72021-05-13 09:08:53 -050076 </dl>
77 </b-col>
78 <b-col sm="6" xl="4">
79 <dl>
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070080 <!-- Status state -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053081 <dt>{{ $t('pageInventory.table.statusState') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050082 <dd>{{ dataFormatter(item.statusState) }}</dd>
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070083 </dl>
Dixsie Wolmersdd652d72021-05-13 09:08:53 -050084 <dl>
85 <!-- Health Rollup state -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053086 <dt>{{ $t('pageInventory.table.statusHealthRollup') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050087 <dd>{{ dataFormatter(item.healthRollup) }}</dd>
Dixsie Wolmersdd652d72021-05-13 09:08:53 -050088 </dl>
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070089 </b-col>
90 </b-row>
91 </b-container>
92 </template>
93 </b-table>
94 </page-section>
95</template>
96
97<script>
98import PageSection from '@/components/Global/PageSection';
99import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
Sukanya Pandey99010962020-07-27 21:44:47 +0530100import TableCellCount from '@/components/Global/TableCellCount';
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700101
102import StatusIcon from '@/components/Global/StatusIcon';
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500103import DataFormatterMixin from '@/components/Mixins/DataFormatterMixin';
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700104import TableSortMixin from '@/components/Mixins/TableSortMixin';
Yoshie Muranakac069c672020-06-18 14:21:50 -0700105import Search from '@/components/Global/Search';
SurenNewareba91c492020-10-27 14:18:54 +0530106import SearchFilterMixin, {
107 searchFilter,
108} from '@/components/Mixins/SearchFilterMixin';
109import TableRowExpandMixin, {
110 expandRowLabel,
111} from '@/components/Mixins/TableRowExpandMixin';
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700112
113export default {
Sukanya Pandey99010962020-07-27 21:44:47 +0530114 components: { IconChevron, PageSection, StatusIcon, Search, TableCellCount },
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500115 mixins: [
116 TableRowExpandMixin,
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500117 DataFormatterMixin,
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500118 TableSortMixin,
Derick Montague602e98a2020-10-21 16:20:00 -0500119 SearchFilterMixin,
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500120 ],
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700121 data() {
122 return {
123 fields: [
124 {
125 key: 'expandRow',
126 label: '',
127 tdClass: 'table-row-expand',
Derick Montague602e98a2020-10-21 16:20:00 -0500128 sortable: false,
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700129 },
130 {
131 key: 'id',
Sandeepa Singh7affc522021-07-06 16:29:10 +0530132 label: this.$t('pageInventory.table.id'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500133 formatter: this.dataFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500134 sortable: true,
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700135 },
136 {
137 key: 'health',
Sandeepa Singh7affc522021-07-06 16:29:10 +0530138 label: this.$t('pageInventory.table.health'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500139 formatter: this.dataFormatter,
Dixsie Wolmersa04d46f2020-10-22 06:34:56 -0500140 sortable: true,
Derick Montague602e98a2020-10-21 16:20:00 -0500141 tdClass: 'text-nowrap',
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700142 },
143 {
Sandeepa Singh7affc522021-07-06 16:29:10 +0530144 key: 'partNumber',
145 label: this.$t('pageInventory.table.partNumber'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500146 formatter: this.dataFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500147 sortable: true,
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700148 },
149 {
Sandeepa Singh7affc522021-07-06 16:29:10 +0530150 key: 'serialNumber',
151 label: this.$t('pageInventory.table.serialNumber'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500152 formatter: this.dataFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500153 },
Yoshie Muranakac069c672020-06-18 14:21:50 -0700154 ],
SurenNewareba91c492020-10-27 14:18:54 +0530155 searchFilter: searchFilter,
Derick Montague602e98a2020-10-21 16:20:00 -0500156 searchTotalFilteredRows: 0,
SurenNewareba91c492020-10-27 14:18:54 +0530157 expandRowLabel: expandRowLabel,
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700158 };
159 },
160 computed: {
Sukanya Pandey99010962020-07-27 21:44:47 +0530161 filteredRows() {
162 return this.searchFilter
163 ? this.searchTotalFilteredRows
164 : this.fans.length;
165 },
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700166 fans() {
167 return this.$store.getters['fan/fans'];
Derick Montague602e98a2020-10-21 16:20:00 -0500168 },
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700169 },
170 created() {
171 this.$store.dispatch('fan/getFanInfo').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500172 // Emit initial data fetch complete to parent component
Sukanya Pandeyedb8a772020-10-29 11:33:42 +0530173 this.$root.$emit('hardware-status-fans-complete');
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700174 });
175 },
176 methods: {
177 sortCompare(a, b, key) {
178 if (key === 'health') {
179 return this.sortStatus(a, b, key);
180 }
Yoshie Muranakac069c672020-06-18 14:21:50 -0700181 },
Sukanya Pandey99010962020-07-27 21:44:47 +0530182 onFiltered(filteredItems) {
183 this.searchTotalFilteredRows = filteredItems.length;
Derick Montague602e98a2020-10-21 16:20:00 -0500184 },
185 },
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700186};
187</script>