Yoshie Muranaka | 5918b48 | 2020-06-08 08:18:23 -0700 | [diff] [blame] | 1 | <template> |
| 2 | <page-section :section-title="$t('pageHardwareStatus.powerSupplies')"> |
SurenNeware | 787635a | 2020-11-24 22:42:42 +0530 | [diff] [blame] | 3 | <b-row class="align-items-end"> |
Yoshie Muranaka | 130b1b6 | 2020-06-18 14:29:57 -0700 | [diff] [blame] | 4 | <b-col sm="6" md="5" xl="4"> |
Dixsie Wolmers | 9b22b49 | 2020-09-07 21:26:06 -0500 | [diff] [blame] | 5 | <search |
Sukanya Pandey | edb8a77 | 2020-10-29 11:33:42 +0530 | [diff] [blame] | 6 | @change-search="onChangeSearchInput" |
| 7 | @clear-search="onClearSearchInput" |
Dixsie Wolmers | 9b22b49 | 2020-09-07 21:26:06 -0500 | [diff] [blame] | 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 |
Sukanya Pandey | fde429e | 2020-09-14 20:48:39 +0530 | [diff] [blame] | 20 | hover |
SurenNeware | 5e25e28 | 2020-07-08 15:57:23 +0530 | [diff] [blame] | 21 | responsive="md" |
Yoshie Muranaka | 5918b48 | 2020-06-08 08:18:23 -0700 | [diff] [blame] | 22 | sort-by="health" |
SurenNeware | 307382e | 2020-07-27 20:45:14 +0530 | [diff] [blame] | 23 | show-empty |
Yoshie Muranaka | 5918b48 | 2020-06-08 08:18:23 -0700 | [diff] [blame] | 24 | :items="powerSupplies" |
| 25 | :fields="fields" |
| 26 | :sort-desc="true" |
| 27 | :sort-compare="sortCompare" |
Yoshie Muranaka | 130b1b6 | 2020-06-18 14:29:57 -0700 | [diff] [blame] | 28 | :filter="searchFilter" |
SurenNeware | 307382e | 2020-07-27 20:45:14 +0530 | [diff] [blame] | 29 | :empty-text="$t('global.table.emptyMessage')" |
SurenNeware | 156a0e6 | 2020-08-28 19:20:03 +0530 | [diff] [blame] | 30 | :empty-filtered-text="$t('global.table.emptySearchMessage')" |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 31 | @filtered="onFiltered" |
Yoshie Muranaka | 5918b48 | 2020-06-08 08:18:23 -0700 | [diff] [blame] | 32 | > |
| 33 | <!-- Expand chevron icon --> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 34 | <template #cell(expandRow)="row"> |
Dixsie Wolmers | 8313376 | 2020-07-15 08:45:19 -0500 | [diff] [blame] | 35 | <b-button |
| 36 | variant="link" |
| 37 | data-test-id="hardwareStatus-button-expandPowerSupplies" |
Dixsie Wolmers | 30f11f8 | 2020-11-10 16:07:56 -0600 | [diff] [blame] | 38 | :title="expandRowLabel" |
| 39 | class="btn-icon-only" |
Dixsie Wolmers | b53e086 | 2020-09-08 14:13:38 -0500 | [diff] [blame] | 40 | @click="toggleRowDetails(row)" |
Dixsie Wolmers | 8313376 | 2020-07-15 08:45:19 -0500 | [diff] [blame] | 41 | > |
Dixsie Wolmers | 30f11f8 | 2020-11-10 16:07:56 -0600 | [diff] [blame] | 42 | <icon-chevron /> |
SurenNeware | 6e2cb97 | 2020-12-24 20:58:16 +0530 | [diff] [blame^] | 43 | <span class="sr-only">{{ expandRowLabel }}</span> |
Yoshie Muranaka | 5918b48 | 2020-06-08 08:18:23 -0700 | [diff] [blame] | 44 | </b-button> |
| 45 | </template> |
| 46 | |
| 47 | <!-- Health --> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 48 | <template #cell(health)="{ value }"> |
Yoshie Muranaka | 5918b48 | 2020-06-08 08:18:23 -0700 | [diff] [blame] | 49 | <status-icon :status="statusIcon(value)" /> |
| 50 | {{ value }} |
| 51 | </template> |
| 52 | |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 53 | <template #row-details="{ item }"> |
Yoshie Muranaka | 5918b48 | 2020-06-08 08:18:23 -0700 | [diff] [blame] | 54 | <b-container fluid> |
| 55 | <b-row> |
| 56 | <b-col sm="6" xl="4"> |
| 57 | <dl> |
| 58 | <!-- Efficiency percent --> |
| 59 | <dt>{{ $t('pageHardwareStatus.table.efficiencyPercent') }}:</dt> |
| 60 | <dd>{{ tableFormatter(item.efficiencyPercent) }}</dd> |
| 61 | <br /> |
| 62 | <!-- Firmware version --> |
| 63 | <dt>{{ $t('pageHardwareStatus.table.firmwareVersion') }}:</dt> |
| 64 | <dd>{{ tableFormatter(item.firmwareVersion) }}</dd> |
| 65 | <br /> |
| 66 | <!-- Indicator LED --> |
| 67 | <dt>{{ $t('pageHardwareStatus.table.indicatorLed') }}:</dt> |
| 68 | <dd>{{ tableFormatter(item.indicatorLed) }}</dd> |
| 69 | </dl> |
| 70 | </b-col> |
| 71 | <b-col sm="6" xl="4"> |
| 72 | <dl> |
| 73 | <!-- Model --> |
| 74 | <dt>{{ $t('pageHardwareStatus.table.model') }}:</dt> |
| 75 | <dd>{{ tableFormatter(item.model) }}</dd> |
| 76 | <br /> |
| 77 | <!-- Power input watts --> |
| 78 | <dt>{{ $t('pageHardwareStatus.table.powerInputWatts') }}:</dt> |
| 79 | <dd>{{ tableFormatter(item.powerInputWatts) }}</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 | |
| 97 | import StatusIcon from '@/components/Global/StatusIcon'; |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 98 | import TableCellCount from '@/components/Global/TableCellCount'; |
Yoshie Muranaka | 386df45 | 2020-06-18 12:45:13 -0700 | [diff] [blame] | 99 | import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin'; |
Yoshie Muranaka | 5918b48 | 2020-06-08 08:18:23 -0700 | [diff] [blame] | 100 | import TableSortMixin from '@/components/Mixins/TableSortMixin'; |
Yoshie Muranaka | 130b1b6 | 2020-06-18 14:29:57 -0700 | [diff] [blame] | 101 | import Search from '@/components/Global/Search'; |
SurenNeware | ba91c49 | 2020-10-27 14:18:54 +0530 | [diff] [blame] | 102 | import SearchFilterMixin, { |
| 103 | searchFilter, |
| 104 | } from '@/components/Mixins/SearchFilterMixin'; |
| 105 | import TableRowExpandMixin, { |
| 106 | expandRowLabel, |
| 107 | } from '@/components/Mixins/TableRowExpandMixin'; |
Yoshie Muranaka | 5918b48 | 2020-06-08 08:18:23 -0700 | [diff] [blame] | 108 | |
| 109 | export default { |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 110 | components: { IconChevron, PageSection, StatusIcon, Search, TableCellCount }, |
Dixsie Wolmers | b53e086 | 2020-09-08 14:13:38 -0500 | [diff] [blame] | 111 | mixins: [ |
| 112 | TableRowExpandMixin, |
| 113 | TableDataFormatterMixin, |
| 114 | TableSortMixin, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 115 | SearchFilterMixin, |
Dixsie Wolmers | b53e086 | 2020-09-08 14:13:38 -0500 | [diff] [blame] | 116 | ], |
Yoshie Muranaka | 5918b48 | 2020-06-08 08:18:23 -0700 | [diff] [blame] | 117 | data() { |
| 118 | return { |
| 119 | fields: [ |
| 120 | { |
| 121 | key: 'expandRow', |
| 122 | label: '', |
| 123 | tdClass: 'table-row-expand', |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 124 | sortable: false, |
Yoshie Muranaka | 5918b48 | 2020-06-08 08:18:23 -0700 | [diff] [blame] | 125 | }, |
| 126 | { |
| 127 | key: 'id', |
| 128 | label: this.$t('pageHardwareStatus.table.id'), |
| 129 | formatter: this.tableFormatter, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 130 | sortable: true, |
Yoshie Muranaka | 5918b48 | 2020-06-08 08:18:23 -0700 | [diff] [blame] | 131 | }, |
| 132 | { |
| 133 | key: 'health', |
| 134 | label: this.$t('pageHardwareStatus.table.health'), |
| 135 | formatter: this.tableFormatter, |
Dixsie Wolmers | a04d46f | 2020-10-22 06:34:56 -0500 | [diff] [blame] | 136 | sortable: true, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 137 | tdClass: 'text-nowrap', |
Yoshie Muranaka | 5918b48 | 2020-06-08 08:18:23 -0700 | [diff] [blame] | 138 | }, |
| 139 | { |
| 140 | key: 'partNumber', |
| 141 | label: this.$t('pageHardwareStatus.table.partNumber'), |
| 142 | formatter: this.tableFormatter, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 143 | sortable: true, |
Yoshie Muranaka | 5918b48 | 2020-06-08 08:18:23 -0700 | [diff] [blame] | 144 | }, |
| 145 | { |
| 146 | key: 'serialNumber', |
| 147 | label: this.$t('pageHardwareStatus.table.serialNumber'), |
| 148 | formatter: this.tableFormatter, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 149 | sortable: true, |
| 150 | }, |
Yoshie Muranaka | 130b1b6 | 2020-06-18 14:29:57 -0700 | [diff] [blame] | 151 | ], |
SurenNeware | ba91c49 | 2020-10-27 14:18:54 +0530 | [diff] [blame] | 152 | searchFilter: searchFilter, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 153 | searchTotalFilteredRows: 0, |
SurenNeware | ba91c49 | 2020-10-27 14:18:54 +0530 | [diff] [blame] | 154 | expandRowLabel: expandRowLabel, |
Yoshie Muranaka | 5918b48 | 2020-06-08 08:18:23 -0700 | [diff] [blame] | 155 | }; |
| 156 | }, |
| 157 | computed: { |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 158 | filteredRows() { |
| 159 | return this.searchFilter |
| 160 | ? this.searchTotalFilteredRows |
| 161 | : this.powerSupplies.length; |
| 162 | }, |
Yoshie Muranaka | 5918b48 | 2020-06-08 08:18:23 -0700 | [diff] [blame] | 163 | powerSupplies() { |
| 164 | return this.$store.getters['powerSupply/powerSupplies']; |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 165 | }, |
Yoshie Muranaka | 5918b48 | 2020-06-08 08:18:23 -0700 | [diff] [blame] | 166 | }, |
| 167 | created() { |
| 168 | this.$store.dispatch('powerSupply/getPowerSupply').finally(() => { |
Gunnar Mills | defc9e2 | 2020-07-07 20:29:03 -0500 | [diff] [blame] | 169 | // Emit initial data fetch complete to parent component |
Sukanya Pandey | edb8a77 | 2020-10-29 11:33:42 +0530 | [diff] [blame] | 170 | this.$root.$emit('hardware-status-power-supplies-complete'); |
Yoshie Muranaka | 5918b48 | 2020-06-08 08:18:23 -0700 | [diff] [blame] | 171 | }); |
| 172 | }, |
| 173 | methods: { |
| 174 | sortCompare(a, b, key) { |
| 175 | if (key === 'health') { |
| 176 | return this.sortStatus(a, b, key); |
| 177 | } |
Yoshie Muranaka | 130b1b6 | 2020-06-18 14:29:57 -0700 | [diff] [blame] | 178 | }, |
Sukanya Pandey | 9901096 | 2020-07-27 21:44:47 +0530 | [diff] [blame] | 179 | onFiltered(filteredItems) { |
| 180 | this.searchTotalFilteredRows = filteredItems.length; |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 181 | }, |
| 182 | }, |
Yoshie Muranaka | 5918b48 | 2020-06-08 08:18:23 -0700 | [diff] [blame] | 183 | }; |
| 184 | </script> |