SurenNeware | dc3fa2e | 2020-08-04 20:45:25 +0530 | [diff] [blame] | 1 | <template> |
| 2 | <page-section :section-title="$t('pageHardwareStatus.processors')"> |
| 3 | <!-- Search --> |
| 4 | <b-row> |
| 5 | <b-col sm="6" md="5" xl="4"> |
| 6 | <search @changeSearch="onChangeSearchInput" /> |
| 7 | </b-col> |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 8 | <b-col sm="6" md="3" xl="2"> |
| 9 | <table-cell-count |
| 10 | :filtered-items-count="filteredRows" |
| 11 | :total-number-of-cells="processors.length" |
| 12 | ></table-cell-count> |
| 13 | </b-col> |
SurenNeware | dc3fa2e | 2020-08-04 20:45:25 +0530 | [diff] [blame] | 14 | </b-row> |
| 15 | <b-table |
| 16 | sort-icon-left |
| 17 | no-sort-reset |
| 18 | responsive="md" |
SurenNeware | 10fe276 | 2020-08-19 12:01:32 +0530 | [diff] [blame] | 19 | show-empty |
SurenNeware | dc3fa2e | 2020-08-04 20:45:25 +0530 | [diff] [blame] | 20 | :items="processors" |
| 21 | :fields="fields" |
| 22 | :sort-desc="true" |
| 23 | :filter="searchFilter" |
SurenNeware | 10fe276 | 2020-08-19 12:01:32 +0530 | [diff] [blame] | 24 | :empty-text="$t('global.table.emptyMessage')" |
SurenNeware | 156a0e6 | 2020-08-28 19:20:03 +0530 | [diff] [blame] | 25 | :empty-filtered-text="$t('global.table.emptySearchMessage')" |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 26 | @filtered="onFiltered" |
SurenNeware | dc3fa2e | 2020-08-04 20:45:25 +0530 | [diff] [blame] | 27 | > |
| 28 | <!-- Expand button --> |
| 29 | <template v-slot:cell(expandRow)="row"> |
| 30 | <b-button |
| 31 | variant="link" |
| 32 | data-test-id="hardwareStatus-button-expandProcessors" |
| 33 | @click="row.toggleDetails" |
| 34 | > |
| 35 | <icon-chevron /> |
| 36 | </b-button> |
| 37 | </template> |
| 38 | <!-- Health --> |
| 39 | <template v-slot:cell(health)="{ value }"> |
| 40 | <status-icon :status="statusIcon(value)" /> |
| 41 | {{ value }} |
| 42 | </template> |
| 43 | <template v-slot:row-details="{ item }"> |
| 44 | <b-container fluid> |
| 45 | <b-row> |
| 46 | <b-col sm="6" xl="4"> |
| 47 | <dl> |
| 48 | <!-- Name --> |
| 49 | <dt>{{ $t('pageHardwareStatus.table.name') }}:</dt> |
| 50 | <dd>{{ tableFormatter(item.name) }}</dd> |
| 51 | <br /> |
| 52 | <!-- Model --> |
| 53 | <dt>{{ $t('pageHardwareStatus.table.model') }}:</dt> |
| 54 | <dd>{{ tableFormatter(item.model) }}</dd> |
| 55 | <br /> |
| 56 | <!-- Instruction set --> |
| 57 | <dt>{{ $t('pageHardwareStatus.table.instructionSet') }}:</dt> |
| 58 | <dd>{{ tableFormatter(item.instructionSet) }}</dd> |
| 59 | <br /> |
| 60 | <!-- Manufacturer --> |
| 61 | <dt>{{ $t('pageHardwareStatus.table.manufacturer') }}:</dt> |
| 62 | <dd>{{ tableFormatter(item.manufacturer) }}</dd> |
| 63 | </dl> |
| 64 | </b-col> |
| 65 | <b-col sm="6" xl="4"> |
| 66 | <dl> |
| 67 | <!-- Architecture --> |
| 68 | <dt> |
| 69 | {{ $t('pageHardwareStatus.table.processorArchitecture') }}: |
| 70 | </dt> |
| 71 | <dd>{{ tableFormatter(item.processorArchitecture) }}</dd> |
| 72 | <br /> |
| 73 | <!-- Type --> |
| 74 | <dt>{{ $t('pageHardwareStatus.table.processorType') }}:</dt> |
| 75 | <dd>{{ tableFormatter(item.processorType) }}</dd> |
| 76 | <br /> |
| 77 | <!-- Total cores --> |
| 78 | <dt>{{ $t('pageHardwareStatus.table.totalCores') }}:</dt> |
| 79 | <dd>{{ tableFormatter(item.totalCores) }}</dd> |
| 80 | <br /> |
| 81 | <!-- Status state --> |
| 82 | <dt>{{ $t('pageHardwareStatus.table.statusState') }}:</dt> |
| 83 | <dd>{{ tableFormatter(item.statusState) }}</dd> |
| 84 | </dl> |
| 85 | </b-col> |
| 86 | </b-row> |
| 87 | </b-container> |
| 88 | </template> |
| 89 | </b-table> |
| 90 | </page-section> |
| 91 | </template> |
| 92 | |
| 93 | <script> |
| 94 | import PageSection from '@/components/Global/PageSection'; |
| 95 | import IconChevron from '@carbon/icons-vue/es/chevron--down/20'; |
| 96 | import StatusIcon from '@/components/Global/StatusIcon'; |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 97 | import TableCellCount from '@/components/Global/TableCellCount'; |
SurenNeware | dc3fa2e | 2020-08-04 20:45:25 +0530 | [diff] [blame] | 98 | |
| 99 | import TableSortMixin from '@/components/Mixins/TableSortMixin'; |
| 100 | import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin'; |
| 101 | import Search from '@/components/Global/Search'; |
| 102 | |
| 103 | export default { |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 104 | components: { PageSection, IconChevron, TableCellCount, StatusIcon, Search }, |
SurenNeware | dc3fa2e | 2020-08-04 20:45:25 +0530 | [diff] [blame] | 105 | mixins: [TableDataFormatterMixin, TableSortMixin], |
| 106 | data() { |
| 107 | return { |
| 108 | fields: [ |
| 109 | { |
| 110 | key: 'expandRow', |
| 111 | label: '', |
| 112 | tdClass: 'table-row-expand', |
| 113 | sortable: false |
| 114 | }, |
| 115 | { |
| 116 | key: 'id', |
| 117 | label: this.$t('pageHardwareStatus.table.id'), |
| 118 | formatter: this.tableFormatter, |
| 119 | sortable: true |
| 120 | }, |
| 121 | { |
| 122 | key: 'health', |
| 123 | label: this.$t('pageHardwareStatus.table.health'), |
| 124 | formatter: this.tableFormatter, |
| 125 | sortable: true |
| 126 | }, |
| 127 | { |
| 128 | key: 'partNumber', |
| 129 | label: this.$t('pageHardwareStatus.table.partNumber'), |
| 130 | formatter: this.tableFormatter, |
| 131 | sortable: true |
| 132 | }, |
| 133 | { |
| 134 | key: 'serialNumber', |
| 135 | label: this.$t('pageHardwareStatus.table.serialNumber'), |
| 136 | formatter: this.tableFormatter, |
| 137 | sortable: true |
| 138 | } |
| 139 | ], |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 140 | searchFilter: null, |
| 141 | searchTotalFilteredRows: 0 |
SurenNeware | dc3fa2e | 2020-08-04 20:45:25 +0530 | [diff] [blame] | 142 | }; |
| 143 | }, |
| 144 | computed: { |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 145 | filteredRows() { |
| 146 | return this.searchFilter |
| 147 | ? this.searchTotalFilteredRows |
| 148 | : this.processors.length; |
| 149 | }, |
SurenNeware | dc3fa2e | 2020-08-04 20:45:25 +0530 | [diff] [blame] | 150 | processors() { |
| 151 | return this.$store.getters['processors/processors']; |
| 152 | } |
| 153 | }, |
| 154 | created() { |
| 155 | this.$store.dispatch('processors/getProcessorsInfo').finally(() => { |
| 156 | // Emit initial data fetch complete to parent component |
| 157 | this.$root.$emit('hardwareStatus::processors::complete'); |
| 158 | }); |
| 159 | }, |
| 160 | methods: { |
| 161 | onChangeSearchInput(searchValue) { |
| 162 | this.searchFilter = searchValue; |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 163 | }, |
| 164 | onFiltered(filteredItems) { |
| 165 | this.searchTotalFilteredRows = filteredItems.length; |
SurenNeware | dc3fa2e | 2020-08-04 20:45:25 +0530 | [diff] [blame] | 166 | } |
| 167 | } |
| 168 | }; |
| 169 | </script> |