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