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