blob: ddc3333cf1a835e890db790e806b71e22e46e7eb [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
Farah Rasheeddb2940a2024-07-25 14:04:18 -050054 <!-- StatusState -->
55 <template #cell(statusState)="{ value }">
56 <status-icon :status="statusStateIcon(value)" />
57 {{ value }}
58 </template>
59
Derick Montague602e98a2020-10-21 16:20:00 -050060 <template #row-details="{ item }">
Yoshie Muranaka5918b482020-06-08 08:18:23 -070061 <b-container fluid>
62 <b-row>
63 <b-col sm="6" xl="4">
64 <dl>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -050065 <!-- Name -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053066 <dt>{{ $t('pageInventory.table.name') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050067 <dd>{{ dataFormatter(item.name) }}</dd>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -050068 <!-- Part number -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053069 <dt>{{ $t('pageInventory.table.partNumber') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050070 <dd>{{ dataFormatter(item.partNumber) }}</dd>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -050071 <!-- Serial number -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053072 <dt>{{ $t('pageInventory.table.serialNumber') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050073 <dd>{{ dataFormatter(item.serialNumber) }}</dd>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -050074 <!-- Spare part number -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053075 <dt>{{ $t('pageInventory.table.sparePartNumber') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050076 <dd>{{ dataFormatter(item.sparePartNumber) }}</dd>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -050077 <!-- Model -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053078 <dt>{{ $t('pageInventory.table.model') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050079 <dd>{{ dataFormatter(item.model) }}</dd>
Yoshie Muranaka5918b482020-06-08 08:18:23 -070080 </dl>
81 </b-col>
82 <b-col sm="6" xl="4">
83 <dl>
Yoshie Muranaka5918b482020-06-08 08:18:23 -070084 <!-- Status state -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053085 <dt>{{ $t('pageInventory.table.statusState') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050086 <dd>{{ dataFormatter(item.statusState) }}</dd>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -050087 <!-- Status Health rollup state -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053088 <dt>{{ $t('pageInventory.table.statusHealthRollup') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050089 <dd>{{ dataFormatter(item.statusHealth) }}</dd>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -050090 <!-- Efficiency percent -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053091 <dt>{{ $t('pageInventory.table.efficiencyPercent') }}:</dt>
Glukhov Mikhaild0b078f2022-12-24 12:16:53 +030092 <dd>
93 {{ dataFormatter(item.efficiencyPercent) }}
94 {{ $t('unit.Percent') }}
95 </dd>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -050096 <!-- Power input watts -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053097 <dt>{{ $t('pageInventory.table.powerInputWatts') }}:</dt>
Glukhov Mikhaild0b078f2022-12-24 12:16:53 +030098 <dd>
99 {{ dataFormatter(item.powerInputWatts) }}
100 {{ $t('unit.W') }}
101 </dd>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -0500102 </dl>
103 </b-col>
104 </b-row>
105 <div class="section-divider mb-3 mt-3"></div>
106 <b-row>
107 <b-col sm="6" xl="4">
108 <dl>
109 <!-- Manufacturer -->
Sandeepa Singh7affc522021-07-06 16:29:10 +0530110 <dt>{{ $t('pageInventory.table.manufacturer') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500111 <dd>{{ dataFormatter(item.manufacturer) }}</dd>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -0500112 </dl>
113 </b-col>
114 <b-col sm="6" xl="4">
115 <dl>
116 <!-- Firmware version -->
Sandeepa Singh7affc522021-07-06 16:29:10 +0530117 <dt>{{ $t('pageInventory.table.firmwareVersion') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500118 <dd>{{ dataFormatter(item.firmwareVersion) }}</dd>
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700119 </dl>
120 </b-col>
121 </b-row>
122 </b-container>
123 </template>
124 </b-table>
125 </page-section>
126</template>
127
128<script>
129import PageSection from '@/components/Global/PageSection';
130import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
131
132import StatusIcon from '@/components/Global/StatusIcon';
Sukanya Pandey99010962020-07-27 21:44:47 +0530133import TableCellCount from '@/components/Global/TableCellCount';
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500134import DataFormatterMixin from '@/components/Mixins/DataFormatterMixin';
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700135import TableSortMixin from '@/components/Mixins/TableSortMixin';
Yoshie Muranaka130b1b62020-06-18 14:29:57 -0700136import Search from '@/components/Global/Search';
SurenNewareba91c492020-10-27 14:18:54 +0530137import SearchFilterMixin, {
138 searchFilter,
139} from '@/components/Mixins/SearchFilterMixin';
140import TableRowExpandMixin, {
141 expandRowLabel,
142} from '@/components/Mixins/TableRowExpandMixin';
Surya Vde23ea22024-07-11 15:19:46 +0530143import { useI18n } from 'vue-i18n';
144import i18n from '@/i18n';
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700145
146export default {
Sukanya Pandey99010962020-07-27 21:44:47 +0530147 components: { IconChevron, PageSection, StatusIcon, Search, TableCellCount },
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500148 mixins: [
149 TableRowExpandMixin,
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500150 DataFormatterMixin,
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500151 TableSortMixin,
Derick Montague602e98a2020-10-21 16:20:00 -0500152 SearchFilterMixin,
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500153 ],
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700154 data() {
155 return {
Surya Vde23ea22024-07-11 15:19:46 +0530156 $t: useI18n().t,
Kenneth Fullbright41057852021-12-27 16:19:37 -0600157 isBusy: true,
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700158 fields: [
159 {
160 key: 'expandRow',
161 label: '',
162 tdClass: 'table-row-expand',
Derick Montague602e98a2020-10-21 16:20:00 -0500163 sortable: false,
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700164 },
165 {
166 key: 'id',
Surya Vde23ea22024-07-11 15:19:46 +0530167 label: i18n.global.t('pageInventory.table.id'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500168 formatter: this.dataFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500169 sortable: true,
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700170 },
171 {
172 key: 'health',
Surya Vde23ea22024-07-11 15:19:46 +0530173 label: i18n.global.t('pageInventory.table.health'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500174 formatter: this.dataFormatter,
Dixsie Wolmersa04d46f2020-10-22 06:34:56 -0500175 sortable: true,
Derick Montague602e98a2020-10-21 16:20:00 -0500176 tdClass: 'text-nowrap',
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700177 },
178 {
Farah Rasheeddb2940a2024-07-25 14:04:18 -0500179 key: 'statusState',
Surya Venkatesan825059a2024-10-04 19:40:42 +0530180 label: i18n.global.t('pageInventory.table.state'),
Farah Rasheeddb2940a2024-07-25 14:04:18 -0500181 formatter: this.dataFormatter,
182 tdClass: 'text-nowrap',
183 },
184 {
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -0500185 key: 'locationNumber',
Surya Vde23ea22024-07-11 15:19:46 +0530186 label: i18n.global.t('pageInventory.table.locationNumber'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500187 formatter: this.dataFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500188 sortable: true,
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700189 },
190 {
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -0500191 key: 'identifyLed',
Surya Vde23ea22024-07-11 15:19:46 +0530192 label: i18n.global.t('pageInventory.table.identifyLed'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500193 formatter: this.dataFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500194 },
Yoshie Muranaka130b1b62020-06-18 14:29:57 -0700195 ],
SurenNewareba91c492020-10-27 14:18:54 +0530196 searchFilter: searchFilter,
Derick Montague602e98a2020-10-21 16:20:00 -0500197 searchTotalFilteredRows: 0,
SurenNewareba91c492020-10-27 14:18:54 +0530198 expandRowLabel: expandRowLabel,
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700199 };
200 },
201 computed: {
Sukanya Pandey99010962020-07-27 21:44:47 +0530202 filteredRows() {
203 return this.searchFilter
204 ? this.searchTotalFilteredRows
205 : this.powerSupplies.length;
206 },
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700207 powerSupplies() {
208 return this.$store.getters['powerSupply/powerSupplies'];
Derick Montague602e98a2020-10-21 16:20:00 -0500209 },
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700210 },
211 created() {
MichalX Szopinskidca9b0a2021-05-07 13:14:50 +0200212 this.$store.dispatch('powerSupply/getAllPowerSupplies').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500213 // Emit initial data fetch complete to parent component
Sukanya Pandeyedb8a772020-10-29 11:33:42 +0530214 this.$root.$emit('hardware-status-power-supplies-complete');
Kenneth Fullbright41057852021-12-27 16:19:37 -0600215 this.isBusy = false;
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700216 });
217 },
218 methods: {
219 sortCompare(a, b, key) {
220 if (key === 'health') {
221 return this.sortStatus(a, b, key);
Farah Rasheeddb2940a2024-07-25 14:04:18 -0500222 } else if (key === 'statusState') {
223 return this.sortStatusState(a, b, key);
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700224 }
Yoshie Muranaka130b1b62020-06-18 14:29:57 -0700225 },
Sukanya Pandey99010962020-07-27 21:44:47 +0530226 onFiltered(filteredItems) {
227 this.searchTotalFilteredRows = filteredItems.length;
Derick Montague602e98a2020-10-21 16:20:00 -0500228 },
Farah Rasheeddb2940a2024-07-25 14:04:18 -0500229 /**
230 * Returns the icon to use for status state based on the given status.
231 * @param {string} status The status to determine the icon for.
232 * @return {string} The icon for the given status.
233 */
234 statusStateIcon(status) {
235 switch (status) {
236 case 'Enabled':
237 return 'success';
238 case 'Absent':
239 return 'warning';
240 default:
241 return '';
242 }
243 },
244 /**
245 * Sorts the status state of two objects based on the provided key.
246 * @param {Object} a The first object to compare.
247 * @param {Object} b The second object to compare.
248 * @param {string} key The key to use for comparison.
249 */
250 sortStatusState(a, b, key) {
251 const statusState = ['Enabled', 'Absent'];
252 return statusState.indexOf(a[key]) - statusState.indexOf(b[key]);
253 },
Derick Montague602e98a2020-10-21 16:20:00 -0500254 },
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700255};
256</script>