blob: e955eda3ba409d3d916af69f4a50a85bfc41221d [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
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 -->
34 <template v-slot:cell(expandRow)="row">
Dixsie Wolmers83133762020-07-15 08:45:19 -050035 <b-button
36 variant="link"
37 data-test-id="hardwareStatus-button-expandFans"
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050038 :aria-label="expandRowLabel"
39 @click="toggleRowDetails(row)"
Dixsie Wolmers83133762020-07-15 08:45:19 -050040 >
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050041 <icon-chevron :title="expandRowLabel" />
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070042 </b-button>
43 </template>
44
45 <!-- Health -->
46 <template v-slot:cell(health)="{ value }">
47 <status-icon :status="statusIcon(value)" />
48 {{ value }}
49 </template>
50
51 <template v-slot:row-details="{ item }">
52 <b-container fluid>
53 <b-row>
54 <b-col sm="6" xl="4">
55 <dl>
56 <!-- Status state -->
57 <dt>{{ $t('pageHardwareStatus.table.statusState') }}:</dt>
58 <dd>{{ tableFormatter(item.statusState) }}</dd>
59 </dl>
60 </b-col>
61 </b-row>
62 </b-container>
63 </template>
64 </b-table>
65 </page-section>
66</template>
67
68<script>
69import PageSection from '@/components/Global/PageSection';
70import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
Sukanya Pandey99010962020-07-27 21:44:47 +053071import TableCellCount from '@/components/Global/TableCellCount';
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070072
73import StatusIcon from '@/components/Global/StatusIcon';
Yoshie Muranaka386df452020-06-18 12:45:13 -070074import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin';
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070075import TableSortMixin from '@/components/Mixins/TableSortMixin';
Yoshie Muranakac069c672020-06-18 14:21:50 -070076import Search from '@/components/Global/Search';
Dixsie Wolmers9b22b492020-09-07 21:26:06 -050077import SearchFilterMixin from '@/components/Mixins/SearchFilterMixin';
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050078import TableRowExpandMixin from '@/components/Mixins/TableRowExpandMixin';
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070079
80export default {
Sukanya Pandey99010962020-07-27 21:44:47 +053081 components: { IconChevron, PageSection, StatusIcon, Search, TableCellCount },
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050082 mixins: [
83 TableRowExpandMixin,
84 TableDataFormatterMixin,
85 TableSortMixin,
86 SearchFilterMixin
87 ],
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070088 data() {
89 return {
90 fields: [
91 {
92 key: 'expandRow',
93 label: '',
94 tdClass: 'table-row-expand',
95 sortable: false
96 },
97 {
98 key: 'id',
99 label: this.$t('pageHardwareStatus.table.id'),
100 formatter: this.tableFormatter,
101 sortable: true
102 },
103 {
104 key: 'health',
105 label: this.$t('pageHardwareStatus.table.health'),
106 formatter: this.tableFormatter,
107 sortable: true
108 },
109 {
110 key: 'partNumber',
111 label: this.$t('pageHardwareStatus.table.partNumber'),
112 formatter: this.tableFormatter,
113 sortable: true
114 },
115 {
116 key: 'serialNumber',
117 label: this.$t('pageHardwareStatus.table.serialNumber'),
118 formatter: this.tableFormatter,
119 sortable: true
120 }
Yoshie Muranakac069c672020-06-18 14:21:50 -0700121 ],
Sukanya Pandey99010962020-07-27 21:44:47 +0530122 searchTotalFilteredRows: 0
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700123 };
124 },
125 computed: {
Sukanya Pandey99010962020-07-27 21:44:47 +0530126 filteredRows() {
127 return this.searchFilter
128 ? this.searchTotalFilteredRows
129 : this.fans.length;
130 },
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700131 fans() {
132 return this.$store.getters['fan/fans'];
133 }
134 },
135 created() {
136 this.$store.dispatch('fan/getFanInfo').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500137 // Emit initial data fetch complete to parent component
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700138 this.$root.$emit('hardwareStatus::fans::complete');
139 });
140 },
141 methods: {
142 sortCompare(a, b, key) {
143 if (key === 'health') {
144 return this.sortStatus(a, b, key);
145 }
Yoshie Muranakac069c672020-06-18 14:21:50 -0700146 },
Sukanya Pandey99010962020-07-27 21:44:47 +0530147 onFiltered(filteredItems) {
148 this.searchTotalFilteredRows = filteredItems.length;
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700149 }
150 }
151};
152</script>