1<template> 2 <page-section :section-title="$t('pageInventory.powerSupplies')"> 3 <b-row class="align-items-end"> 4 <b-col sm="6" md="5" xl="4"> 5 <search 6 @change-search="onChangeSearchInput" 7 @clear-search="onClearSearchInput" 8 /> 9 </b-col> 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> 16 </b-row> 17 <b-table 18 sort-icon-left 19 no-sort-reset 20 hover 21 responsive="md" 22 sort-by="health" 23 show-empty 24 :items="powerSupplies" 25 :fields="fields" 26 :sort-desc="true" 27 :sort-compare="sortCompare" 28 :filter="searchFilter" 29 :empty-text="$t('global.table.emptyMessage')" 30 :empty-filtered-text="$t('global.table.emptySearchMessage')" 31 :busy="isBusy" 32 @filtered="onFiltered" 33 > 34 <!-- Expand chevron icon --> 35 <template #cell(expandRow)="row"> 36 <b-button 37 variant="link" 38 data-test-id="hardwareStatus-button-expandPowerSupplies" 39 :title="expandRowLabel" 40 class="btn-icon-only" 41 @click="toggleRowDetails(row)" 42 > 43 <icon-chevron /> 44 <span class="sr-only">{{ expandRowLabel }}</span> 45 </b-button> 46 </template> 47 48 <!-- Health --> 49 <template #cell(health)="{ value }"> 50 <status-icon :status="statusIcon(value)" /> 51 {{ value }} 52 </template> 53 54 <template #row-details="{ item }"> 55 <b-container fluid> 56 <b-row> 57 <b-col sm="6" xl="4"> 58 <dl> 59 <!-- Name --> 60 <dt>{{ $t('pageInventory.table.name') }}:</dt> 61 <dd>{{ dataFormatter(item.name) }}</dd> 62 <!-- Part number --> 63 <dt>{{ $t('pageInventory.table.partNumber') }}:</dt> 64 <dd>{{ dataFormatter(item.partNumber) }}</dd> 65 <!-- Serial number --> 66 <dt>{{ $t('pageInventory.table.serialNumber') }}:</dt> 67 <dd>{{ dataFormatter(item.serialNumber) }}</dd> 68 <!-- Spare part number --> 69 <dt>{{ $t('pageInventory.table.sparePartNumber') }}:</dt> 70 <dd>{{ dataFormatter(item.sparePartNumber) }}</dd> 71 <!-- Model --> 72 <dt>{{ $t('pageInventory.table.model') }}:</dt> 73 <dd>{{ dataFormatter(item.model) }}</dd> 74 </dl> 75 </b-col> 76 <b-col sm="6" xl="4"> 77 <dl> 78 <!-- Status state --> 79 <dt>{{ $t('pageInventory.table.statusState') }}:</dt> 80 <dd>{{ dataFormatter(item.statusState) }}</dd> 81 <!-- Status Health rollup state --> 82 <dt>{{ $t('pageInventory.table.statusHealthRollup') }}:</dt> 83 <dd>{{ dataFormatter(item.statusHealth) }}</dd> 84 <!-- Efficiency percent --> 85 <dt>{{ $t('pageInventory.table.efficiencyPercent') }}:</dt> 86 <dd>{{ dataFormatter(item.efficiencyPercent) }}</dd> 87 <!-- Power input watts --> 88 <dt>{{ $t('pageInventory.table.powerInputWatts') }}:</dt> 89 <dd>{{ dataFormatter(item.powerInputWatts) }}</dd> 90 </dl> 91 </b-col> 92 </b-row> 93 <div class="section-divider mb-3 mt-3"></div> 94 <b-row> 95 <b-col sm="6" xl="4"> 96 <dl> 97 <!-- Manufacturer --> 98 <dt>{{ $t('pageInventory.table.manufacturer') }}:</dt> 99 <dd>{{ dataFormatter(item.manufacturer) }}</dd> 100 </dl> 101 </b-col> 102 <b-col sm="6" xl="4"> 103 <dl> 104 <!-- Firmware version --> 105 <dt>{{ $t('pageInventory.table.firmwareVersion') }}:</dt> 106 <dd>{{ dataFormatter(item.firmwareVersion) }}</dd> 107 </dl> 108 </b-col> 109 </b-row> 110 </b-container> 111 </template> 112 </b-table> 113 </page-section> 114</template> 115 116<script> 117import PageSection from '@/components/Global/PageSection'; 118import IconChevron from '@carbon/icons-vue/es/chevron--down/20'; 119 120import StatusIcon from '@/components/Global/StatusIcon'; 121import TableCellCount from '@/components/Global/TableCellCount'; 122import DataFormatterMixin from '@/components/Mixins/DataFormatterMixin'; 123import TableSortMixin from '@/components/Mixins/TableSortMixin'; 124import Search from '@/components/Global/Search'; 125import SearchFilterMixin, { 126 searchFilter, 127} from '@/components/Mixins/SearchFilterMixin'; 128import TableRowExpandMixin, { 129 expandRowLabel, 130} from '@/components/Mixins/TableRowExpandMixin'; 131 132export default { 133 components: { IconChevron, PageSection, StatusIcon, Search, TableCellCount }, 134 mixins: [ 135 TableRowExpandMixin, 136 DataFormatterMixin, 137 TableSortMixin, 138 SearchFilterMixin, 139 ], 140 data() { 141 return { 142 isBusy: true, 143 fields: [ 144 { 145 key: 'expandRow', 146 label: '', 147 tdClass: 'table-row-expand', 148 sortable: false, 149 }, 150 { 151 key: 'id', 152 label: this.$t('pageInventory.table.id'), 153 formatter: this.dataFormatter, 154 sortable: true, 155 }, 156 { 157 key: 'health', 158 label: this.$t('pageInventory.table.health'), 159 formatter: this.dataFormatter, 160 sortable: true, 161 tdClass: 'text-nowrap', 162 }, 163 { 164 key: 'locationNumber', 165 label: this.$t('pageInventory.table.locationNumber'), 166 formatter: this.dataFormatter, 167 sortable: true, 168 }, 169 { 170 key: 'identifyLed', 171 label: this.$t('pageInventory.table.identifyLed'), 172 formatter: this.dataFormatter, 173 }, 174 ], 175 searchFilter: searchFilter, 176 searchTotalFilteredRows: 0, 177 expandRowLabel: expandRowLabel, 178 }; 179 }, 180 computed: { 181 filteredRows() { 182 return this.searchFilter 183 ? this.searchTotalFilteredRows 184 : this.powerSupplies.length; 185 }, 186 powerSupplies() { 187 return this.$store.getters['powerSupply/powerSupplies']; 188 }, 189 }, 190 created() { 191 this.$store.dispatch('powerSupply/getAllPowerSupplies').finally(() => { 192 // Emit initial data fetch complete to parent component 193 this.$root.$emit('hardware-status-power-supplies-complete'); 194 this.isBusy = false; 195 }); 196 }, 197 methods: { 198 sortCompare(a, b, key) { 199 if (key === 'health') { 200 return this.sortStatus(a, b, key); 201 } 202 }, 203 onFiltered(filteredItems) { 204 this.searchTotalFilteredRows = filteredItems.length; 205 }, 206 }, 207}; 208</script> 209