blob: aed7871a5e442e59bda67809832d033b12611c98 [file] [log] [blame]
Yoshie Muranaka5918b482020-06-08 08:18:23 -07001<template>
Sandeepa Singh7affc522021-07-06 16:29:10 +05302 <page-section :section-title="$t('pageInventory.powerSupplies')">
SurenNeware787635a2020-11-24 22:42:42 +05303 <b-row class="align-items-end">
Yoshie Muranaka130b1b62020-06-18 14:29:57 -07004 <b-col sm="6" md="5" xl="4">
Dixsie Wolmers9b22b492020-09-07 21:26:06 -05005 <search
Sukanya Pandeyedb8a772020-10-29 11:33:42 +05306 @change-search="onChangeSearchInput"
7 @clear-search="onClearSearchInput"
Dixsie Wolmers9b22b492020-09-07 21:26:06 -05008 />
Yoshie Muranaka130b1b62020-06-18 14:29:57 -07009 </b-col>
Sukanya Pandey99010962020-07-27 21:44:47 +053010 <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 Muranaka130b1b62020-06-18 14:29:57 -070016 </b-row>
Yoshie Muranaka5918b482020-06-08 08:18:23 -070017 <b-table
18 sort-icon-left
19 no-sort-reset
Sukanya Pandeyfde429e2020-09-14 20:48:39 +053020 hover
SurenNeware5e25e282020-07-08 15:57:23 +053021 responsive="md"
Yoshie Muranaka5918b482020-06-08 08:18:23 -070022 sort-by="health"
SurenNeware307382e2020-07-27 20:45:14 +053023 show-empty
Yoshie Muranaka5918b482020-06-08 08:18:23 -070024 :items="powerSupplies"
25 :fields="fields"
26 :sort-desc="true"
27 :sort-compare="sortCompare"
Yoshie Muranaka130b1b62020-06-18 14:29:57 -070028 :filter="searchFilter"
SurenNeware307382e2020-07-27 20:45:14 +053029 :empty-text="$t('global.table.emptyMessage')"
SurenNeware156a0e62020-08-28 19:20:03 +053030 :empty-filtered-text="$t('global.table.emptySearchMessage')"
Kenneth Fullbright41057852021-12-27 16:19:37 -060031 :busy="isBusy"
Sukanya Pandey99010962020-07-27 21:44:47 +053032 @filtered="onFiltered"
Yoshie Muranaka5918b482020-06-08 08:18:23 -070033 >
34 <!-- Expand chevron icon -->
Derick Montague602e98a2020-10-21 16:20:00 -050035 <template #cell(expandRow)="row">
Dixsie Wolmers83133762020-07-15 08:45:19 -050036 <b-button
37 variant="link"
38 data-test-id="hardwareStatus-button-expandPowerSupplies"
Dixsie Wolmers30f11f82020-11-10 16:07:56 -060039 :title="expandRowLabel"
40 class="btn-icon-only"
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050041 @click="toggleRowDetails(row)"
Dixsie Wolmers83133762020-07-15 08:45:19 -050042 >
Dixsie Wolmers30f11f82020-11-10 16:07:56 -060043 <icon-chevron />
SurenNeware6e2cb972020-12-24 20:58:16 +053044 <span class="sr-only">{{ expandRowLabel }}</span>
Yoshie Muranaka5918b482020-06-08 08:18:23 -070045 </b-button>
46 </template>
47
48 <!-- Health -->
Derick Montague602e98a2020-10-21 16:20:00 -050049 <template #cell(health)="{ value }">
Yoshie Muranaka5918b482020-06-08 08:18:23 -070050 <status-icon :status="statusIcon(value)" />
51 {{ value }}
52 </template>
53
Derick Montague602e98a2020-10-21 16:20:00 -050054 <template #row-details="{ item }">
Yoshie Muranaka5918b482020-06-08 08:18:23 -070055 <b-container fluid>
56 <b-row>
57 <b-col sm="6" xl="4">
58 <dl>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -050059 <!-- Name -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053060 <dt>{{ $t('pageInventory.table.name') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050061 <dd>{{ dataFormatter(item.name) }}</dd>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -050062 <!-- Part number -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053063 <dt>{{ $t('pageInventory.table.partNumber') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050064 <dd>{{ dataFormatter(item.partNumber) }}</dd>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -050065 <!-- Serial number -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053066 <dt>{{ $t('pageInventory.table.serialNumber') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050067 <dd>{{ dataFormatter(item.serialNumber) }}</dd>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -050068 <!-- Spare part number -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053069 <dt>{{ $t('pageInventory.table.sparePartNumber') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050070 <dd>{{ dataFormatter(item.sparePartNumber) }}</dd>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -050071 <!-- Model -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053072 <dt>{{ $t('pageInventory.table.model') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050073 <dd>{{ dataFormatter(item.model) }}</dd>
Yoshie Muranaka5918b482020-06-08 08:18:23 -070074 </dl>
75 </b-col>
76 <b-col sm="6" xl="4">
77 <dl>
Yoshie Muranaka5918b482020-06-08 08:18:23 -070078 <!-- Status state -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053079 <dt>{{ $t('pageInventory.table.statusState') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050080 <dd>{{ dataFormatter(item.statusState) }}</dd>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -050081 <!-- Status Health rollup state -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053082 <dt>{{ $t('pageInventory.table.statusHealthRollup') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050083 <dd>{{ dataFormatter(item.statusHealth) }}</dd>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -050084 <!-- Efficiency percent -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053085 <dt>{{ $t('pageInventory.table.efficiencyPercent') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050086 <dd>{{ dataFormatter(item.efficiencyPercent) }}</dd>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -050087 <!-- Power input watts -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053088 <dt>{{ $t('pageInventory.table.powerInputWatts') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050089 <dd>{{ dataFormatter(item.powerInputWatts) }}</dd>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -050090 </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 -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053098 <dt>{{ $t('pageInventory.table.manufacturer') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050099 <dd>{{ dataFormatter(item.manufacturer) }}</dd>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -0500100 </dl>
101 </b-col>
102 <b-col sm="6" xl="4">
103 <dl>
104 <!-- Firmware version -->
Sandeepa Singh7affc522021-07-06 16:29:10 +0530105 <dt>{{ $t('pageInventory.table.firmwareVersion') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500106 <dd>{{ dataFormatter(item.firmwareVersion) }}</dd>
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700107 </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';
Sukanya Pandey99010962020-07-27 21:44:47 +0530121import TableCellCount from '@/components/Global/TableCellCount';
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500122import DataFormatterMixin from '@/components/Mixins/DataFormatterMixin';
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700123import TableSortMixin from '@/components/Mixins/TableSortMixin';
Yoshie Muranaka130b1b62020-06-18 14:29:57 -0700124import Search from '@/components/Global/Search';
SurenNewareba91c492020-10-27 14:18:54 +0530125import SearchFilterMixin, {
126 searchFilter,
127} from '@/components/Mixins/SearchFilterMixin';
128import TableRowExpandMixin, {
129 expandRowLabel,
130} from '@/components/Mixins/TableRowExpandMixin';
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700131
132export default {
Sukanya Pandey99010962020-07-27 21:44:47 +0530133 components: { IconChevron, PageSection, StatusIcon, Search, TableCellCount },
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500134 mixins: [
135 TableRowExpandMixin,
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500136 DataFormatterMixin,
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500137 TableSortMixin,
Derick Montague602e98a2020-10-21 16:20:00 -0500138 SearchFilterMixin,
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500139 ],
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700140 data() {
141 return {
Kenneth Fullbright41057852021-12-27 16:19:37 -0600142 isBusy: true,
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700143 fields: [
144 {
145 key: 'expandRow',
146 label: '',
147 tdClass: 'table-row-expand',
Derick Montague602e98a2020-10-21 16:20:00 -0500148 sortable: false,
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700149 },
150 {
151 key: 'id',
Sandeepa Singh7affc522021-07-06 16:29:10 +0530152 label: this.$t('pageInventory.table.id'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500153 formatter: this.dataFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500154 sortable: true,
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700155 },
156 {
157 key: 'health',
Sandeepa Singh7affc522021-07-06 16:29:10 +0530158 label: this.$t('pageInventory.table.health'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500159 formatter: this.dataFormatter,
Dixsie Wolmersa04d46f2020-10-22 06:34:56 -0500160 sortable: true,
Derick Montague602e98a2020-10-21 16:20:00 -0500161 tdClass: 'text-nowrap',
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700162 },
163 {
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -0500164 key: 'locationNumber',
Sandeepa Singh7affc522021-07-06 16:29:10 +0530165 label: this.$t('pageInventory.table.locationNumber'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500166 formatter: this.dataFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500167 sortable: true,
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700168 },
169 {
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -0500170 key: 'identifyLed',
Sandeepa Singh7affc522021-07-06 16:29:10 +0530171 label: this.$t('pageInventory.table.identifyLed'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500172 formatter: this.dataFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500173 },
Yoshie Muranaka130b1b62020-06-18 14:29:57 -0700174 ],
SurenNewareba91c492020-10-27 14:18:54 +0530175 searchFilter: searchFilter,
Derick Montague602e98a2020-10-21 16:20:00 -0500176 searchTotalFilteredRows: 0,
SurenNewareba91c492020-10-27 14:18:54 +0530177 expandRowLabel: expandRowLabel,
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700178 };
179 },
180 computed: {
Sukanya Pandey99010962020-07-27 21:44:47 +0530181 filteredRows() {
182 return this.searchFilter
183 ? this.searchTotalFilteredRows
184 : this.powerSupplies.length;
185 },
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700186 powerSupplies() {
187 return this.$store.getters['powerSupply/powerSupplies'];
Derick Montague602e98a2020-10-21 16:20:00 -0500188 },
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700189 },
190 created() {
MichalX Szopinskidca9b0a2021-05-07 13:14:50 +0200191 this.$store.dispatch('powerSupply/getAllPowerSupplies').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500192 // Emit initial data fetch complete to parent component
Sukanya Pandeyedb8a772020-10-29 11:33:42 +0530193 this.$root.$emit('hardware-status-power-supplies-complete');
Kenneth Fullbright41057852021-12-27 16:19:37 -0600194 this.isBusy = false;
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700195 });
196 },
197 methods: {
198 sortCompare(a, b, key) {
199 if (key === 'health') {
200 return this.sortStatus(a, b, key);
201 }
Yoshie Muranaka130b1b62020-06-18 14:29:57 -0700202 },
Sukanya Pandey99010962020-07-27 21:44:47 +0530203 onFiltered(filteredItems) {
204 this.searchTotalFilteredRows = filteredItems.length;
Derick Montague602e98a2020-10-21 16:20:00 -0500205 },
206 },
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700207};
208</script>