blob: 9ee9291c1539891ee95855cfadbe00a6bd87ea2c [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,
Dixsie Wolmersa04d46f2020-10-22 06:34:56 -0500107 sortable: true,
108 tdClass: 'text-nowrap'
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700109 },
110 {
111 key: 'partNumber',
112 label: this.$t('pageHardwareStatus.table.partNumber'),
113 formatter: this.tableFormatter,
114 sortable: true
115 },
116 {
117 key: 'serialNumber',
118 label: this.$t('pageHardwareStatus.table.serialNumber'),
119 formatter: this.tableFormatter,
120 sortable: true
121 }
Yoshie Muranakac069c672020-06-18 14:21:50 -0700122 ],
Sukanya Pandey99010962020-07-27 21:44:47 +0530123 searchTotalFilteredRows: 0
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700124 };
125 },
126 computed: {
Sukanya Pandey99010962020-07-27 21:44:47 +0530127 filteredRows() {
128 return this.searchFilter
129 ? this.searchTotalFilteredRows
130 : this.fans.length;
131 },
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700132 fans() {
133 return this.$store.getters['fan/fans'];
134 }
135 },
136 created() {
137 this.$store.dispatch('fan/getFanInfo').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500138 // Emit initial data fetch complete to parent component
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700139 this.$root.$emit('hardwareStatus::fans::complete');
140 });
141 },
142 methods: {
143 sortCompare(a, b, key) {
144 if (key === 'health') {
145 return this.sortStatus(a, b, key);
146 }
Yoshie Muranakac069c672020-06-18 14:21:50 -0700147 },
Sukanya Pandey99010962020-07-27 21:44:47 +0530148 onFiltered(filteredItems) {
149 this.searchTotalFilteredRows = filteredItems.length;
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700150 }
151 }
152};
153</script>