Yoshie Muranaka | e24b17d | 2020-06-08 11:03:11 -0700 | [diff] [blame] | 1 | <template> |
| 2 | <page-section :section-title="$t('pageHardwareStatus.dimmSlot')"> |
Yoshie Muranaka | 4177014 | 2020-06-18 14:00:55 -0700 | [diff] [blame] | 3 | <b-row> |
| 4 | <b-col sm="6" md="5" xl="4"> |
| 5 | <search @changeSearch="onChangeSearchInput" /> |
| 6 | </b-col> |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame^] | 7 | <b-col sm="6" md="3" xl="2"> |
| 8 | <table-cell-count |
| 9 | :filtered-items-count="filteredRows" |
| 10 | :total-number-of-cells="dimms.length" |
| 11 | ></table-cell-count> |
| 12 | </b-col> |
Yoshie Muranaka | 4177014 | 2020-06-18 14:00:55 -0700 | [diff] [blame] | 13 | </b-row> |
Yoshie Muranaka | e24b17d | 2020-06-08 11:03:11 -0700 | [diff] [blame] | 14 | <b-table |
| 15 | sort-icon-left |
| 16 | no-sort-reset |
| 17 | sort-by="health" |
SurenNeware | 5e25e28 | 2020-07-08 15:57:23 +0530 | [diff] [blame] | 18 | responsive="md" |
SurenNeware | 307382e | 2020-07-27 20:45:14 +0530 | [diff] [blame] | 19 | show-empty |
Yoshie Muranaka | e24b17d | 2020-06-08 11:03:11 -0700 | [diff] [blame] | 20 | :items="dimms" |
| 21 | :fields="fields" |
| 22 | :sort-desc="true" |
| 23 | :sort-compare="sortCompare" |
Yoshie Muranaka | 4177014 | 2020-06-18 14:00:55 -0700 | [diff] [blame] | 24 | :filter="searchFilter" |
SurenNeware | 307382e | 2020-07-27 20:45:14 +0530 | [diff] [blame] | 25 | :empty-text="$t('global.table.emptyMessage')" |
SurenNeware | 156a0e6 | 2020-08-28 19:20:03 +0530 | [diff] [blame] | 26 | :empty-filtered-text="$t('global.table.emptySearchMessage')" |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame^] | 27 | @filtered="onFiltered" |
Yoshie Muranaka | e24b17d | 2020-06-08 11:03:11 -0700 | [diff] [blame] | 28 | > |
| 29 | <!-- Expand chevron icon --> |
| 30 | <template v-slot:cell(expandRow)="row"> |
Dixsie Wolmers | 8313376 | 2020-07-15 08:45:19 -0500 | [diff] [blame] | 31 | <b-button |
| 32 | variant="link" |
| 33 | data-test-id="hardwareStatus-button-expandDimms" |
| 34 | @click="row.toggleDetails" |
| 35 | > |
Yoshie Muranaka | e24b17d | 2020-06-08 11:03:11 -0700 | [diff] [blame] | 36 | <icon-chevron /> |
| 37 | </b-button> |
| 38 | </template> |
| 39 | |
| 40 | <!-- Health --> |
| 41 | <template v-slot:cell(health)="{ value }"> |
| 42 | <status-icon :status="statusIcon(value)" /> |
| 43 | {{ value }} |
| 44 | </template> |
| 45 | |
| 46 | <template v-slot:row-details="{ item }"> |
| 47 | <b-container fluid> |
| 48 | <b-row> |
| 49 | <b-col sm="6" xl="4"> |
| 50 | <dl> |
| 51 | <!-- Status state --> |
| 52 | <dt>{{ $t('pageHardwareStatus.table.statusState') }}:</dt> |
| 53 | <dd>{{ tableFormatter(item.statusState) }}</dd> |
| 54 | </dl> |
| 55 | </b-col> |
| 56 | </b-row> |
| 57 | </b-container> |
| 58 | </template> |
| 59 | </b-table> |
| 60 | </page-section> |
| 61 | </template> |
| 62 | |
| 63 | <script> |
| 64 | import PageSection from '@/components/Global/PageSection'; |
| 65 | import IconChevron from '@carbon/icons-vue/es/chevron--down/20'; |
| 66 | |
| 67 | import StatusIcon from '@/components/Global/StatusIcon'; |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame^] | 68 | import TableCellCount from '@/components/Global/TableCellCount'; |
| 69 | |
Yoshie Muranaka | 386df45 | 2020-06-18 12:45:13 -0700 | [diff] [blame] | 70 | import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin'; |
Yoshie Muranaka | e24b17d | 2020-06-08 11:03:11 -0700 | [diff] [blame] | 71 | import TableSortMixin from '@/components/Mixins/TableSortMixin'; |
Yoshie Muranaka | 4177014 | 2020-06-18 14:00:55 -0700 | [diff] [blame] | 72 | import Search from '@/components/Global/Search'; |
Yoshie Muranaka | e24b17d | 2020-06-08 11:03:11 -0700 | [diff] [blame] | 73 | |
| 74 | export default { |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame^] | 75 | components: { IconChevron, PageSection, StatusIcon, Search, TableCellCount }, |
Yoshie Muranaka | 386df45 | 2020-06-18 12:45:13 -0700 | [diff] [blame] | 76 | mixins: [TableDataFormatterMixin, TableSortMixin], |
Yoshie Muranaka | e24b17d | 2020-06-08 11:03:11 -0700 | [diff] [blame] | 77 | data() { |
| 78 | return { |
| 79 | fields: [ |
| 80 | { |
| 81 | key: 'expandRow', |
| 82 | label: '', |
| 83 | tdClass: 'table-row-expand', |
| 84 | sortable: false |
| 85 | }, |
| 86 | { |
| 87 | key: 'id', |
| 88 | label: this.$t('pageHardwareStatus.table.id'), |
| 89 | formatter: this.tableFormatter, |
| 90 | sortable: true |
| 91 | }, |
| 92 | { |
| 93 | key: 'health', |
| 94 | label: this.$t('pageHardwareStatus.table.health'), |
| 95 | formatter: this.tableFormatter, |
| 96 | sortable: true |
| 97 | }, |
| 98 | { |
| 99 | key: 'partNumber', |
| 100 | label: this.$t('pageHardwareStatus.table.partNumber'), |
| 101 | formatter: this.tableFormatter, |
| 102 | sortable: true |
| 103 | }, |
| 104 | { |
| 105 | key: 'serialNumber', |
| 106 | label: this.$t('pageHardwareStatus.table.serialNumber'), |
| 107 | formatter: this.tableFormatter, |
| 108 | sortable: true |
| 109 | } |
Yoshie Muranaka | 4177014 | 2020-06-18 14:00:55 -0700 | [diff] [blame] | 110 | ], |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame^] | 111 | searchFilter: null, |
| 112 | searchTotalFilteredRows: 0 |
Yoshie Muranaka | e24b17d | 2020-06-08 11:03:11 -0700 | [diff] [blame] | 113 | }; |
| 114 | }, |
| 115 | computed: { |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame^] | 116 | filteredRows() { |
| 117 | return this.searchFilter |
| 118 | ? this.searchTotalFilteredRows |
| 119 | : this.dimms.length; |
| 120 | }, |
Yoshie Muranaka | e24b17d | 2020-06-08 11:03:11 -0700 | [diff] [blame] | 121 | dimms() { |
| 122 | return this.$store.getters['memory/dimms']; |
| 123 | } |
| 124 | }, |
| 125 | created() { |
| 126 | this.$store.dispatch('memory/getDimms').finally(() => { |
Gunnar Mills | defc9e2 | 2020-07-07 20:29:03 -0500 | [diff] [blame] | 127 | // Emit initial data fetch complete to parent component |
Yoshie Muranaka | e24b17d | 2020-06-08 11:03:11 -0700 | [diff] [blame] | 128 | this.$root.$emit('hardwareStatus::dimmSlot::complete'); |
| 129 | }); |
| 130 | }, |
| 131 | methods: { |
| 132 | sortCompare(a, b, key) { |
| 133 | if (key === 'health') { |
| 134 | return this.sortStatus(a, b, key); |
| 135 | } |
Yoshie Muranaka | 4177014 | 2020-06-18 14:00:55 -0700 | [diff] [blame] | 136 | }, |
| 137 | onChangeSearchInput(searchValue) { |
| 138 | this.searchFilter = searchValue; |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame^] | 139 | }, |
| 140 | onFiltered(filteredItems) { |
| 141 | this.searchTotalFilteredRows = filteredItems.length; |
Yoshie Muranaka | e24b17d | 2020-06-08 11:03:11 -0700 | [diff] [blame] | 142 | } |
| 143 | } |
| 144 | }; |
| 145 | </script> |