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