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