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