Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 1 | <template> |
Sandeepa Singh | 7affc52 | 2021-07-06 16:29:10 +0530 | [diff] [blame] | 2 | <page-section :section-title="$t('pageInventory.fans')"> |
SurenNeware | 787635a | 2020-11-24 22:42:42 +0530 | [diff] [blame] | 3 | <b-row class="align-items-end"> |
Yoshie Muranaka | c069c67 | 2020-06-18 14:21:50 -0700 | [diff] [blame] | 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 | 30f11f8 | 2020-11-10 16:07:56 -0600 | [diff] [blame] | 38 | :title="expandRowLabel" |
| 39 | class="btn-icon-only" |
Dixsie Wolmers | b53e086 | 2020-09-08 14:13:38 -0500 | [diff] [blame] | 40 | @click="toggleRowDetails(row)" |
Dixsie Wolmers | 8313376 | 2020-07-15 08:45:19 -0500 | [diff] [blame] | 41 | > |
Dixsie Wolmers | 30f11f8 | 2020-11-10 16:07:56 -0600 | [diff] [blame] | 42 | <icon-chevron /> |
SurenNeware | 6e2cb97 | 2020-12-24 20:58:16 +0530 | [diff] [blame] | 43 | <span class="sr-only">{{ expandRowLabel }}</span> |
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> |
Dixsie Wolmers | dd652d7 | 2021-05-13 09:08:53 -0500 | [diff] [blame] | 58 | <!-- Name --> |
Sandeepa Singh | 7affc52 | 2021-07-06 16:29:10 +0530 | [diff] [blame] | 59 | <dt>{{ $t('pageInventory.table.name') }}:</dt> |
Dixsie Wolmers | 9726f9a | 2021-09-07 15:33:16 -0500 | [diff] [blame^] | 60 | <dd>{{ dataFormatter(item.name) }}</dd> |
Dixsie Wolmers | dd652d7 | 2021-05-13 09:08:53 -0500 | [diff] [blame] | 61 | </dl> |
| 62 | <dl> |
| 63 | <!-- Serial number --> |
Sandeepa Singh | 7affc52 | 2021-07-06 16:29:10 +0530 | [diff] [blame] | 64 | <dt>{{ $t('pageInventory.table.serialNumber') }}:</dt> |
Dixsie Wolmers | 9726f9a | 2021-09-07 15:33:16 -0500 | [diff] [blame^] | 65 | <dd>{{ dataFormatter(item.serialNumber) }}</dd> |
Dixsie Wolmers | dd652d7 | 2021-05-13 09:08:53 -0500 | [diff] [blame] | 66 | </dl> |
| 67 | <dl> |
| 68 | <!-- Part number --> |
Sandeepa Singh | 7affc52 | 2021-07-06 16:29:10 +0530 | [diff] [blame] | 69 | <dt>{{ $t('pageInventory.table.partNumber') }}:</dt> |
Dixsie Wolmers | 9726f9a | 2021-09-07 15:33:16 -0500 | [diff] [blame^] | 70 | <dd>{{ dataFormatter(item.partNumber) }}</dd> |
Dixsie Wolmers | dd652d7 | 2021-05-13 09:08:53 -0500 | [diff] [blame] | 71 | </dl> |
| 72 | <dl> |
| 73 | <!-- Fan speed --> |
Sandeepa Singh | 7affc52 | 2021-07-06 16:29:10 +0530 | [diff] [blame] | 74 | <dt>{{ $t('pageInventory.table.fanSpeed') }}:</dt> |
Dixsie Wolmers | 9726f9a | 2021-09-07 15:33:16 -0500 | [diff] [blame^] | 75 | <dd>{{ dataFormatter(item.speed) }}</dd> |
Dixsie Wolmers | dd652d7 | 2021-05-13 09:08:53 -0500 | [diff] [blame] | 76 | </dl> |
| 77 | </b-col> |
| 78 | <b-col sm="6" xl="4"> |
| 79 | <dl> |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 80 | <!-- Status state --> |
Sandeepa Singh | 7affc52 | 2021-07-06 16:29:10 +0530 | [diff] [blame] | 81 | <dt>{{ $t('pageInventory.table.statusState') }}:</dt> |
Dixsie Wolmers | 9726f9a | 2021-09-07 15:33:16 -0500 | [diff] [blame^] | 82 | <dd>{{ dataFormatter(item.statusState) }}</dd> |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 83 | </dl> |
Dixsie Wolmers | dd652d7 | 2021-05-13 09:08:53 -0500 | [diff] [blame] | 84 | <dl> |
| 85 | <!-- Health Rollup state --> |
Sandeepa Singh | 7affc52 | 2021-07-06 16:29:10 +0530 | [diff] [blame] | 86 | <dt>{{ $t('pageInventory.table.statusHealthRollup') }}:</dt> |
Dixsie Wolmers | 9726f9a | 2021-09-07 15:33:16 -0500 | [diff] [blame^] | 87 | <dd>{{ dataFormatter(item.healthRollup) }}</dd> |
Dixsie Wolmers | dd652d7 | 2021-05-13 09:08:53 -0500 | [diff] [blame] | 88 | </dl> |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 89 | </b-col> |
| 90 | </b-row> |
| 91 | </b-container> |
| 92 | </template> |
| 93 | </b-table> |
| 94 | </page-section> |
| 95 | </template> |
| 96 | |
| 97 | <script> |
| 98 | import PageSection from '@/components/Global/PageSection'; |
| 99 | import IconChevron from '@carbon/icons-vue/es/chevron--down/20'; |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 100 | import TableCellCount from '@/components/Global/TableCellCount'; |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 101 | |
| 102 | import StatusIcon from '@/components/Global/StatusIcon'; |
Dixsie Wolmers | 9726f9a | 2021-09-07 15:33:16 -0500 | [diff] [blame^] | 103 | import DataFormatterMixin from '@/components/Mixins/DataFormatterMixin'; |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 104 | import TableSortMixin from '@/components/Mixins/TableSortMixin'; |
Yoshie Muranaka | c069c67 | 2020-06-18 14:21:50 -0700 | [diff] [blame] | 105 | import Search from '@/components/Global/Search'; |
SurenNeware | ba91c49 | 2020-10-27 14:18:54 +0530 | [diff] [blame] | 106 | import SearchFilterMixin, { |
| 107 | searchFilter, |
| 108 | } from '@/components/Mixins/SearchFilterMixin'; |
| 109 | import TableRowExpandMixin, { |
| 110 | expandRowLabel, |
| 111 | } from '@/components/Mixins/TableRowExpandMixin'; |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 112 | |
| 113 | export default { |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 114 | components: { IconChevron, PageSection, StatusIcon, Search, TableCellCount }, |
Dixsie Wolmers | b53e086 | 2020-09-08 14:13:38 -0500 | [diff] [blame] | 115 | mixins: [ |
| 116 | TableRowExpandMixin, |
Dixsie Wolmers | 9726f9a | 2021-09-07 15:33:16 -0500 | [diff] [blame^] | 117 | DataFormatterMixin, |
Dixsie Wolmers | b53e086 | 2020-09-08 14:13:38 -0500 | [diff] [blame] | 118 | TableSortMixin, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 119 | SearchFilterMixin, |
Dixsie Wolmers | b53e086 | 2020-09-08 14:13:38 -0500 | [diff] [blame] | 120 | ], |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 121 | data() { |
| 122 | return { |
| 123 | fields: [ |
| 124 | { |
| 125 | key: 'expandRow', |
| 126 | label: '', |
| 127 | tdClass: 'table-row-expand', |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 128 | sortable: false, |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 129 | }, |
| 130 | { |
| 131 | key: 'id', |
Sandeepa Singh | 7affc52 | 2021-07-06 16:29:10 +0530 | [diff] [blame] | 132 | label: this.$t('pageInventory.table.id'), |
Dixsie Wolmers | 9726f9a | 2021-09-07 15:33:16 -0500 | [diff] [blame^] | 133 | formatter: this.dataFormatter, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 134 | sortable: true, |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 135 | }, |
| 136 | { |
| 137 | key: 'health', |
Sandeepa Singh | 7affc52 | 2021-07-06 16:29:10 +0530 | [diff] [blame] | 138 | label: this.$t('pageInventory.table.health'), |
Dixsie Wolmers | 9726f9a | 2021-09-07 15:33:16 -0500 | [diff] [blame^] | 139 | formatter: this.dataFormatter, |
Dixsie Wolmers | a04d46f | 2020-10-22 06:34:56 -0500 | [diff] [blame] | 140 | sortable: true, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 141 | tdClass: 'text-nowrap', |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 142 | }, |
| 143 | { |
Sandeepa Singh | 7affc52 | 2021-07-06 16:29:10 +0530 | [diff] [blame] | 144 | key: 'partNumber', |
| 145 | label: this.$t('pageInventory.table.partNumber'), |
Dixsie Wolmers | 9726f9a | 2021-09-07 15:33:16 -0500 | [diff] [blame^] | 146 | formatter: this.dataFormatter, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 147 | sortable: true, |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 148 | }, |
| 149 | { |
Sandeepa Singh | 7affc52 | 2021-07-06 16:29:10 +0530 | [diff] [blame] | 150 | key: 'serialNumber', |
| 151 | label: this.$t('pageInventory.table.serialNumber'), |
Dixsie Wolmers | 9726f9a | 2021-09-07 15:33:16 -0500 | [diff] [blame^] | 152 | formatter: this.dataFormatter, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 153 | }, |
Yoshie Muranaka | c069c67 | 2020-06-18 14:21:50 -0700 | [diff] [blame] | 154 | ], |
SurenNeware | ba91c49 | 2020-10-27 14:18:54 +0530 | [diff] [blame] | 155 | searchFilter: searchFilter, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 156 | searchTotalFilteredRows: 0, |
SurenNeware | ba91c49 | 2020-10-27 14:18:54 +0530 | [diff] [blame] | 157 | expandRowLabel: expandRowLabel, |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 158 | }; |
| 159 | }, |
| 160 | computed: { |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 161 | filteredRows() { |
| 162 | return this.searchFilter |
| 163 | ? this.searchTotalFilteredRows |
| 164 | : this.fans.length; |
| 165 | }, |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 166 | fans() { |
| 167 | return this.$store.getters['fan/fans']; |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 168 | }, |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 169 | }, |
| 170 | created() { |
| 171 | this.$store.dispatch('fan/getFanInfo').finally(() => { |
Gunnar Mills | defc9e2 | 2020-07-07 20:29:03 -0500 | [diff] [blame] | 172 | // Emit initial data fetch complete to parent component |
Sukanya Pandey | edb8a77 | 2020-10-29 11:33:42 +0530 | [diff] [blame] | 173 | this.$root.$emit('hardware-status-fans-complete'); |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 174 | }); |
| 175 | }, |
| 176 | methods: { |
| 177 | sortCompare(a, b, key) { |
| 178 | if (key === 'health') { |
| 179 | return this.sortStatus(a, b, key); |
| 180 | } |
Yoshie Muranaka | c069c67 | 2020-06-18 14:21:50 -0700 | [diff] [blame] | 181 | }, |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 182 | onFiltered(filteredItems) { |
| 183 | this.searchTotalFilteredRows = filteredItems.length; |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 184 | }, |
| 185 | }, |
Yoshie Muranaka | b89a53c | 2020-06-15 13:25:46 -0700 | [diff] [blame] | 186 | }; |
| 187 | </script> |