blob: ba2e2ced5142388ea5d4eb6f88cc82f574bc8af6 [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
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 Wolmersb53e0862020-09-08 14:13:38 -050038 :aria-label="expandRowLabel"
Dixsie Wolmers30f11f82020-11-10 16:07:56 -060039 :title="expandRowLabel"
40 class="btn-icon-only"
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050041 @click="toggleRowDetails(row)"
Dixsie Wolmers83133762020-07-15 08:45:19 -050042 >
Dixsie Wolmers30f11f82020-11-10 16:07:56 -060043 <icon-chevron />
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>
58 <!-- Status state -->
59 <dt>{{ $t('pageHardwareStatus.table.statusState') }}:</dt>
60 <dd>{{ tableFormatter(item.statusState) }}</dd>
61 </dl>
62 </b-col>
63 </b-row>
64 </b-container>
65 </template>
66 </b-table>
67 </page-section>
68</template>
69
70<script>
71import PageSection from '@/components/Global/PageSection';
72import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
Sukanya Pandey99010962020-07-27 21:44:47 +053073import TableCellCount from '@/components/Global/TableCellCount';
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070074
75import StatusIcon from '@/components/Global/StatusIcon';
Yoshie Muranaka386df452020-06-18 12:45:13 -070076import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin';
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070077import TableSortMixin from '@/components/Mixins/TableSortMixin';
Yoshie Muranakac069c672020-06-18 14:21:50 -070078import Search from '@/components/Global/Search';
SurenNewareba91c492020-10-27 14:18:54 +053079import SearchFilterMixin, {
80 searchFilter,
81} from '@/components/Mixins/SearchFilterMixin';
82import TableRowExpandMixin, {
83 expandRowLabel,
84} from '@/components/Mixins/TableRowExpandMixin';
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070085
86export default {
Sukanya Pandey99010962020-07-27 21:44:47 +053087 components: { IconChevron, PageSection, StatusIcon, Search, TableCellCount },
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050088 mixins: [
89 TableRowExpandMixin,
90 TableDataFormatterMixin,
91 TableSortMixin,
Derick Montague602e98a2020-10-21 16:20:00 -050092 SearchFilterMixin,
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050093 ],
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070094 data() {
95 return {
96 fields: [
97 {
98 key: 'expandRow',
99 label: '',
100 tdClass: 'table-row-expand',
Derick Montague602e98a2020-10-21 16:20:00 -0500101 sortable: false,
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700102 },
103 {
104 key: 'id',
105 label: this.$t('pageHardwareStatus.table.id'),
106 formatter: this.tableFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500107 sortable: true,
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700108 },
109 {
110 key: 'health',
111 label: this.$t('pageHardwareStatus.table.health'),
112 formatter: this.tableFormatter,
Dixsie Wolmersa04d46f2020-10-22 06:34:56 -0500113 sortable: true,
Derick Montague602e98a2020-10-21 16:20:00 -0500114 tdClass: 'text-nowrap',
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700115 },
116 {
117 key: 'partNumber',
118 label: this.$t('pageHardwareStatus.table.partNumber'),
119 formatter: this.tableFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500120 sortable: true,
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700121 },
122 {
123 key: 'serialNumber',
124 label: this.$t('pageHardwareStatus.table.serialNumber'),
125 formatter: this.tableFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500126 sortable: true,
127 },
Yoshie Muranakac069c672020-06-18 14:21:50 -0700128 ],
SurenNewareba91c492020-10-27 14:18:54 +0530129 searchFilter: searchFilter,
Derick Montague602e98a2020-10-21 16:20:00 -0500130 searchTotalFilteredRows: 0,
SurenNewareba91c492020-10-27 14:18:54 +0530131 expandRowLabel: expandRowLabel,
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700132 };
133 },
134 computed: {
Sukanya Pandey99010962020-07-27 21:44:47 +0530135 filteredRows() {
136 return this.searchFilter
137 ? this.searchTotalFilteredRows
138 : this.fans.length;
139 },
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700140 fans() {
141 return this.$store.getters['fan/fans'];
Derick Montague602e98a2020-10-21 16:20:00 -0500142 },
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700143 },
144 created() {
145 this.$store.dispatch('fan/getFanInfo').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500146 // Emit initial data fetch complete to parent component
Sukanya Pandeyedb8a772020-10-29 11:33:42 +0530147 this.$root.$emit('hardware-status-fans-complete');
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700148 });
149 },
150 methods: {
151 sortCompare(a, b, key) {
152 if (key === 'health') {
153 return this.sortStatus(a, b, key);
154 }
Yoshie Muranakac069c672020-06-18 14:21:50 -0700155 },
Sukanya Pandey99010962020-07-27 21:44:47 +0530156 onFiltered(filteredItems) {
157 this.searchTotalFilteredRows = filteredItems.length;
Derick Montague602e98a2020-10-21 16:20:00 -0500158 },
159 },
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700160};
161</script>