blob: 98e2fb5e8259b8a059ae5eb28e3acca9a56fd2da [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"
37 @click="row.toggleDetails"
38 >
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070039 <icon-chevron />
40 </b-button>
41 </template>
42
43 <!-- Health -->
44 <template v-slot:cell(health)="{ value }">
45 <status-icon :status="statusIcon(value)" />
46 {{ value }}
47 </template>
48
49 <template v-slot:row-details="{ item }">
50 <b-container fluid>
51 <b-row>
52 <b-col sm="6" xl="4">
53 <dl>
54 <!-- Status state -->
55 <dt>{{ $t('pageHardwareStatus.table.statusState') }}:</dt>
56 <dd>{{ tableFormatter(item.statusState) }}</dd>
57 </dl>
58 </b-col>
59 </b-row>
60 </b-container>
61 </template>
62 </b-table>
63 </page-section>
64</template>
65
66<script>
67import PageSection from '@/components/Global/PageSection';
68import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
Sukanya Pandey99010962020-07-27 21:44:47 +053069import TableCellCount from '@/components/Global/TableCellCount';
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070070
71import StatusIcon from '@/components/Global/StatusIcon';
Yoshie Muranaka386df452020-06-18 12:45:13 -070072import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin';
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070073import TableSortMixin from '@/components/Mixins/TableSortMixin';
Yoshie Muranakac069c672020-06-18 14:21:50 -070074import Search from '@/components/Global/Search';
Dixsie Wolmers9b22b492020-09-07 21:26:06 -050075import SearchFilterMixin from '@/components/Mixins/SearchFilterMixin';
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070076
77export default {
Sukanya Pandey99010962020-07-27 21:44:47 +053078 components: { IconChevron, PageSection, StatusIcon, Search, TableCellCount },
Dixsie Wolmers9b22b492020-09-07 21:26:06 -050079 mixins: [TableDataFormatterMixin, TableSortMixin, SearchFilterMixin],
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070080 data() {
81 return {
82 fields: [
83 {
84 key: 'expandRow',
85 label: '',
86 tdClass: 'table-row-expand',
87 sortable: false
88 },
89 {
90 key: 'id',
91 label: this.$t('pageHardwareStatus.table.id'),
92 formatter: this.tableFormatter,
93 sortable: true
94 },
95 {
96 key: 'health',
97 label: this.$t('pageHardwareStatus.table.health'),
98 formatter: this.tableFormatter,
99 sortable: true
100 },
101 {
102 key: 'partNumber',
103 label: this.$t('pageHardwareStatus.table.partNumber'),
104 formatter: this.tableFormatter,
105 sortable: true
106 },
107 {
108 key: 'serialNumber',
109 label: this.$t('pageHardwareStatus.table.serialNumber'),
110 formatter: this.tableFormatter,
111 sortable: true
112 }
Yoshie Muranakac069c672020-06-18 14:21:50 -0700113 ],
Sukanya Pandey99010962020-07-27 21:44:47 +0530114 searchTotalFilteredRows: 0
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700115 };
116 },
117 computed: {
Sukanya Pandey99010962020-07-27 21:44:47 +0530118 filteredRows() {
119 return this.searchFilter
120 ? this.searchTotalFilteredRows
121 : this.fans.length;
122 },
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700123 fans() {
124 return this.$store.getters['fan/fans'];
125 }
126 },
127 created() {
128 this.$store.dispatch('fan/getFanInfo').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500129 // Emit initial data fetch complete to parent component
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700130 this.$root.$emit('hardwareStatus::fans::complete');
131 });
132 },
133 methods: {
134 sortCompare(a, b, key) {
135 if (key === 'health') {
136 return this.sortStatus(a, b, key);
137 }
Yoshie Muranakac069c672020-06-18 14:21:50 -0700138 },
Sukanya Pandey99010962020-07-27 21:44:47 +0530139 onFiltered(filteredItems) {
140 this.searchTotalFilteredRows = filteredItems.length;
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700141 }
142 }
143};
144</script>