Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 1 | <template> |
| 2 | <page-section :section-title="$t('pageHardwareStatus.fans')"> |
Yoshie Muranaka | c069c67 | 2020-06-18 14:21:50 -0700 | [diff] [blame] | 3 | <b-row> |
| 4 | <b-col sm="6" md="5" xl="4"> |
Dixsie Wolmers | 9b22b49 | 2020-09-07 21:26:06 -0500 | [diff] [blame] | 5 | <search |
Sukanya Pandey | edb8a77 | 2020-10-29 11:33:42 +0530 | [diff] [blame] | 6 | @change-search="onChangeSearchInput" |
| 7 | @clear-search="onClearSearchInput" |
Dixsie Wolmers | 9b22b49 | 2020-09-07 21:26:06 -0500 | [diff] [blame] | 8 | /> |
Yoshie Muranaka | c069c67 | 2020-06-18 14:21:50 -0700 | [diff] [blame] | 9 | </b-col> |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 10 | <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 Muranaka | c069c67 | 2020-06-18 14:21:50 -0700 | [diff] [blame] | 16 | </b-row> |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 17 | <b-table |
| 18 | sort-icon-left |
| 19 | no-sort-reset |
Sukanya Pandey | fde429e | 2020-09-14 20:48:39 +0530 | [diff] [blame] | 20 | hover |
SurenNeware | 5e25e28 | 2020-07-08 15:57:23 +0530 | [diff] [blame] | 21 | responsive="md" |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 22 | sort-by="health" |
SurenNeware | 307382e | 2020-07-27 20:45:14 +0530 | [diff] [blame] | 23 | show-empty |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 24 | :items="fans" |
| 25 | :fields="fields" |
| 26 | :sort-desc="true" |
| 27 | :sort-compare="sortCompare" |
Yoshie Muranaka | c069c67 | 2020-06-18 14:21:50 -0700 | [diff] [blame] | 28 | :filter="searchFilter" |
SurenNeware | 307382e | 2020-07-27 20:45:14 +0530 | [diff] [blame] | 29 | :empty-text="$t('global.table.emptyMessage')" |
SurenNeware | 156a0e6 | 2020-08-28 19:20:03 +0530 | [diff] [blame] | 30 | :empty-filtered-text="$t('global.table.emptySearchMessage')" |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 31 | @filtered="onFiltered" |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 32 | > |
| 33 | <!-- Expand chevron icon --> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 34 | <template #cell(expandRow)="row"> |
Dixsie Wolmers | 8313376 | 2020-07-15 08:45:19 -0500 | [diff] [blame] | 35 | <b-button |
| 36 | variant="link" |
| 37 | data-test-id="hardwareStatus-button-expandFans" |
Dixsie Wolmers | b53e086 | 2020-09-08 14:13:38 -0500 | [diff] [blame] | 38 | :aria-label="expandRowLabel" |
Dixsie Wolmers | 30f11f8 | 2020-11-10 16:07:56 -0600 | [diff] [blame] | 39 | :title="expandRowLabel" |
| 40 | class="btn-icon-only" |
Dixsie Wolmers | b53e086 | 2020-09-08 14:13:38 -0500 | [diff] [blame] | 41 | @click="toggleRowDetails(row)" |
Dixsie Wolmers | 8313376 | 2020-07-15 08:45:19 -0500 | [diff] [blame] | 42 | > |
Dixsie Wolmers | 30f11f8 | 2020-11-10 16:07:56 -0600 | [diff] [blame] | 43 | <icon-chevron /> |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 44 | </b-button> |
| 45 | </template> |
| 46 | |
| 47 | <!-- Health --> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 48 | <template #cell(health)="{ value }"> |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 49 | <status-icon :status="statusIcon(value)" /> |
| 50 | {{ value }} |
| 51 | </template> |
| 52 | |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 53 | <template #row-details="{ item }"> |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 54 | <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> |
| 71 | import PageSection from '@/components/Global/PageSection'; |
| 72 | import IconChevron from '@carbon/icons-vue/es/chevron--down/20'; |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 73 | import TableCellCount from '@/components/Global/TableCellCount'; |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 74 | |
| 75 | import StatusIcon from '@/components/Global/StatusIcon'; |
Yoshie Muranaka | 386df45 | 2020-06-18 12:45:13 -0700 | [diff] [blame] | 76 | import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin'; |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 77 | import TableSortMixin from '@/components/Mixins/TableSortMixin'; |
Yoshie Muranaka | c069c67 | 2020-06-18 14:21:50 -0700 | [diff] [blame] | 78 | import Search from '@/components/Global/Search'; |
SurenNeware | ba91c49 | 2020-10-27 14:18:54 +0530 | [diff] [blame^] | 79 | import SearchFilterMixin, { |
| 80 | searchFilter, |
| 81 | } from '@/components/Mixins/SearchFilterMixin'; |
| 82 | import TableRowExpandMixin, { |
| 83 | expandRowLabel, |
| 84 | } from '@/components/Mixins/TableRowExpandMixin'; |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 85 | |
| 86 | export default { |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 87 | components: { IconChevron, PageSection, StatusIcon, Search, TableCellCount }, |
Dixsie Wolmers | b53e086 | 2020-09-08 14:13:38 -0500 | [diff] [blame] | 88 | mixins: [ |
| 89 | TableRowExpandMixin, |
| 90 | TableDataFormatterMixin, |
| 91 | TableSortMixin, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 92 | SearchFilterMixin, |
Dixsie Wolmers | b53e086 | 2020-09-08 14:13:38 -0500 | [diff] [blame] | 93 | ], |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 94 | data() { |
| 95 | return { |
| 96 | fields: [ |
| 97 | { |
| 98 | key: 'expandRow', |
| 99 | label: '', |
| 100 | tdClass: 'table-row-expand', |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 101 | sortable: false, |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 102 | }, |
| 103 | { |
| 104 | key: 'id', |
| 105 | label: this.$t('pageHardwareStatus.table.id'), |
| 106 | formatter: this.tableFormatter, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 107 | sortable: true, |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 108 | }, |
| 109 | { |
| 110 | key: 'health', |
| 111 | label: this.$t('pageHardwareStatus.table.health'), |
| 112 | formatter: this.tableFormatter, |
Dixsie Wolmers | a04d46f | 2020-10-22 06:34:56 -0500 | [diff] [blame] | 113 | sortable: true, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 114 | tdClass: 'text-nowrap', |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 115 | }, |
| 116 | { |
| 117 | key: 'partNumber', |
| 118 | label: this.$t('pageHardwareStatus.table.partNumber'), |
| 119 | formatter: this.tableFormatter, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 120 | sortable: true, |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 121 | }, |
| 122 | { |
| 123 | key: 'serialNumber', |
| 124 | label: this.$t('pageHardwareStatus.table.serialNumber'), |
| 125 | formatter: this.tableFormatter, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 126 | sortable: true, |
| 127 | }, |
Yoshie Muranaka | c069c67 | 2020-06-18 14:21:50 -0700 | [diff] [blame] | 128 | ], |
SurenNeware | ba91c49 | 2020-10-27 14:18:54 +0530 | [diff] [blame^] | 129 | searchFilter: searchFilter, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 130 | searchTotalFilteredRows: 0, |
SurenNeware | ba91c49 | 2020-10-27 14:18:54 +0530 | [diff] [blame^] | 131 | expandRowLabel: expandRowLabel, |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 132 | }; |
| 133 | }, |
| 134 | computed: { |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 135 | filteredRows() { |
| 136 | return this.searchFilter |
| 137 | ? this.searchTotalFilteredRows |
| 138 | : this.fans.length; |
| 139 | }, |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 140 | fans() { |
| 141 | return this.$store.getters['fan/fans']; |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 142 | }, |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 143 | }, |
| 144 | created() { |
| 145 | this.$store.dispatch('fan/getFanInfo').finally(() => { |
Gunnar Mills | defc9e2 | 2020-07-07 20:29:03 -0500 | [diff] [blame] | 146 | // Emit initial data fetch complete to parent component |
Sukanya Pandey | edb8a77 | 2020-10-29 11:33:42 +0530 | [diff] [blame] | 147 | this.$root.$emit('hardware-status-fans-complete'); |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 148 | }); |
| 149 | }, |
| 150 | methods: { |
| 151 | sortCompare(a, b, key) { |
| 152 | if (key === 'health') { |
| 153 | return this.sortStatus(a, b, key); |
| 154 | } |
Yoshie Muranaka | c069c67 | 2020-06-18 14:21:50 -0700 | [diff] [blame] | 155 | }, |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 156 | onFiltered(filteredItems) { |
| 157 | this.searchTotalFilteredRows = filteredItems.length; |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 158 | }, |
| 159 | }, |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 160 | }; |
| 161 | </script> |