blob: f35ab9d295e5c9922a97dfae47896a74342990de [file] [log] [blame]
Yoshie Muranakab89a53c2020-06-15 13:25:46 -07001<template>
2 <page-section :section-title="$t('pageHardwareStatus.fans')">
Yoshie Muranakac069c672020-06-18 14:21:50 -07003 <b-row>
4 <b-col sm="6" md="5" xl="4">
Dixsie Wolmers9b22b492020-09-07 21:26:06 -05005 <search
6 @changeSearch="onChangeSearchInput"
7 @clearSearch="onClearSearchInput"
8 />
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
SurenNeware5e25e282020-07-08 15:57:23 +053020 responsive="md"
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070021 sort-by="health"
SurenNeware307382e2020-07-27 20:45:14 +053022 show-empty
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070023 :items="fans"
24 :fields="fields"
25 :sort-desc="true"
26 :sort-compare="sortCompare"
Yoshie Muranakac069c672020-06-18 14:21:50 -070027 :filter="searchFilter"
SurenNeware307382e2020-07-27 20:45:14 +053028 :empty-text="$t('global.table.emptyMessage')"
SurenNeware156a0e62020-08-28 19:20:03 +053029 :empty-filtered-text="$t('global.table.emptySearchMessage')"
Sukanya Pandey99010962020-07-27 21:44:47 +053030 @filtered="onFiltered"
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070031 >
32 <!-- Expand chevron icon -->
33 <template v-slot:cell(expandRow)="row">
Dixsie Wolmers83133762020-07-15 08:45:19 -050034 <b-button
35 variant="link"
36 data-test-id="hardwareStatus-button-expandFans"
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050037 :aria-label="expandRowLabel"
38 @click="toggleRowDetails(row)"
Dixsie Wolmers83133762020-07-15 08:45:19 -050039 >
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050040 <icon-chevron :title="expandRowLabel" />
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070041 </b-button>
42 </template>
43
44 <!-- Health -->
45 <template v-slot:cell(health)="{ value }">
46 <status-icon :status="statusIcon(value)" />
47 {{ value }}
48 </template>
49
50 <template v-slot:row-details="{ item }">
51 <b-container fluid>
52 <b-row>
53 <b-col sm="6" xl="4">
54 <dl>
55 <!-- Status state -->
56 <dt>{{ $t('pageHardwareStatus.table.statusState') }}:</dt>
57 <dd>{{ tableFormatter(item.statusState) }}</dd>
58 </dl>
59 </b-col>
60 </b-row>
61 </b-container>
62 </template>
63 </b-table>
64 </page-section>
65</template>
66
67<script>
68import PageSection from '@/components/Global/PageSection';
69import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
Sukanya Pandey99010962020-07-27 21:44:47 +053070import TableCellCount from '@/components/Global/TableCellCount';
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070071
72import StatusIcon from '@/components/Global/StatusIcon';
Yoshie Muranaka386df452020-06-18 12:45:13 -070073import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin';
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070074import TableSortMixin from '@/components/Mixins/TableSortMixin';
Yoshie Muranakac069c672020-06-18 14:21:50 -070075import Search from '@/components/Global/Search';
Dixsie Wolmers9b22b492020-09-07 21:26:06 -050076import SearchFilterMixin from '@/components/Mixins/SearchFilterMixin';
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050077import TableRowExpandMixin from '@/components/Mixins/TableRowExpandMixin';
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070078
79export default {
Sukanya Pandey99010962020-07-27 21:44:47 +053080 components: { IconChevron, PageSection, StatusIcon, Search, TableCellCount },
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050081 mixins: [
82 TableRowExpandMixin,
83 TableDataFormatterMixin,
84 TableSortMixin,
85 SearchFilterMixin
86 ],
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070087 data() {
88 return {
89 fields: [
90 {
91 key: 'expandRow',
92 label: '',
93 tdClass: 'table-row-expand',
94 sortable: false
95 },
96 {
97 key: 'id',
98 label: this.$t('pageHardwareStatus.table.id'),
99 formatter: this.tableFormatter,
100 sortable: true
101 },
102 {
103 key: 'health',
104 label: this.$t('pageHardwareStatus.table.health'),
105 formatter: this.tableFormatter,
106 sortable: true
107 },
108 {
109 key: 'partNumber',
110 label: this.$t('pageHardwareStatus.table.partNumber'),
111 formatter: this.tableFormatter,
112 sortable: true
113 },
114 {
115 key: 'serialNumber',
116 label: this.$t('pageHardwareStatus.table.serialNumber'),
117 formatter: this.tableFormatter,
118 sortable: true
119 }
Yoshie Muranakac069c672020-06-18 14:21:50 -0700120 ],
Sukanya Pandey99010962020-07-27 21:44:47 +0530121 searchTotalFilteredRows: 0
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700122 };
123 },
124 computed: {
Sukanya Pandey99010962020-07-27 21:44:47 +0530125 filteredRows() {
126 return this.searchFilter
127 ? this.searchTotalFilteredRows
128 : this.fans.length;
129 },
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700130 fans() {
131 return this.$store.getters['fan/fans'];
132 }
133 },
134 created() {
135 this.$store.dispatch('fan/getFanInfo').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500136 // Emit initial data fetch complete to parent component
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700137 this.$root.$emit('hardwareStatus::fans::complete');
138 });
139 },
140 methods: {
141 sortCompare(a, b, key) {
142 if (key === 'health') {
143 return this.sortStatus(a, b, key);
144 }
Yoshie Muranakac069c672020-06-18 14:21:50 -0700145 },
Sukanya Pandey99010962020-07-27 21:44:47 +0530146 onFiltered(filteredItems) {
147 this.searchTotalFilteredRows = filteredItems.length;
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700148 }
149 }
150};
151</script>