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