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