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