blob: ac64673b4edaa42d1c23d4916e7ab446af77cd61 [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>
Glukhov Mikhaild0b078f2022-12-24 12:16:53 +030086 <dd>
87 {{ dataFormatter(item.efficiencyPercent) }}
88 {{ $t('unit.Percent') }}
89 </dd>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -050090 <!-- Power input watts -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053091 <dt>{{ $t('pageInventory.table.powerInputWatts') }}:</dt>
Glukhov Mikhaild0b078f2022-12-24 12:16:53 +030092 <dd>
93 {{ dataFormatter(item.powerInputWatts) }}
94 {{ $t('unit.W') }}
95 </dd>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -050096 </dl>
97 </b-col>
98 </b-row>
99 <div class="section-divider mb-3 mt-3"></div>
100 <b-row>
101 <b-col sm="6" xl="4">
102 <dl>
103 <!-- Manufacturer -->
Sandeepa Singh7affc522021-07-06 16:29:10 +0530104 <dt>{{ $t('pageInventory.table.manufacturer') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500105 <dd>{{ dataFormatter(item.manufacturer) }}</dd>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -0500106 </dl>
107 </b-col>
108 <b-col sm="6" xl="4">
109 <dl>
110 <!-- Firmware version -->
Sandeepa Singh7affc522021-07-06 16:29:10 +0530111 <dt>{{ $t('pageInventory.table.firmwareVersion') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500112 <dd>{{ dataFormatter(item.firmwareVersion) }}</dd>
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700113 </dl>
114 </b-col>
115 </b-row>
116 </b-container>
117 </template>
118 </b-table>
119 </page-section>
120</template>
121
122<script>
123import PageSection from '@/components/Global/PageSection';
124import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
125
126import StatusIcon from '@/components/Global/StatusIcon';
Sukanya Pandey99010962020-07-27 21:44:47 +0530127import TableCellCount from '@/components/Global/TableCellCount';
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500128import DataFormatterMixin from '@/components/Mixins/DataFormatterMixin';
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700129import TableSortMixin from '@/components/Mixins/TableSortMixin';
Yoshie Muranaka130b1b62020-06-18 14:29:57 -0700130import Search from '@/components/Global/Search';
SurenNewareba91c492020-10-27 14:18:54 +0530131import SearchFilterMixin, {
132 searchFilter,
133} from '@/components/Mixins/SearchFilterMixin';
134import TableRowExpandMixin, {
135 expandRowLabel,
136} from '@/components/Mixins/TableRowExpandMixin';
Surya V603cfbf2024-07-11 15:19:46 +0530137import { useI18n } from 'vue-i18n';
138import i18n from '@/i18n';
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700139
140export default {
Sukanya Pandey99010962020-07-27 21:44:47 +0530141 components: { IconChevron, PageSection, StatusIcon, Search, TableCellCount },
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500142 mixins: [
143 TableRowExpandMixin,
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500144 DataFormatterMixin,
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500145 TableSortMixin,
Derick Montague602e98a2020-10-21 16:20:00 -0500146 SearchFilterMixin,
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500147 ],
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700148 data() {
149 return {
Surya V603cfbf2024-07-11 15:19:46 +0530150 $t: useI18n().t,
Kenneth Fullbright41057852021-12-27 16:19:37 -0600151 isBusy: true,
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700152 fields: [
153 {
154 key: 'expandRow',
155 label: '',
156 tdClass: 'table-row-expand',
Derick Montague602e98a2020-10-21 16:20:00 -0500157 sortable: false,
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700158 },
159 {
160 key: 'id',
Surya V603cfbf2024-07-11 15:19:46 +0530161 label: i18n.global.t('pageInventory.table.id'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500162 formatter: this.dataFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500163 sortable: true,
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700164 },
165 {
166 key: 'health',
Surya V603cfbf2024-07-11 15:19:46 +0530167 label: i18n.global.t('pageInventory.table.health'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500168 formatter: this.dataFormatter,
Dixsie Wolmersa04d46f2020-10-22 06:34:56 -0500169 sortable: true,
Derick Montague602e98a2020-10-21 16:20:00 -0500170 tdClass: 'text-nowrap',
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700171 },
172 {
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -0500173 key: 'locationNumber',
Surya V603cfbf2024-07-11 15:19:46 +0530174 label: i18n.global.t('pageInventory.table.locationNumber'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500175 formatter: this.dataFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500176 sortable: true,
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700177 },
178 {
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -0500179 key: 'identifyLed',
Surya V603cfbf2024-07-11 15:19:46 +0530180 label: i18n.global.t('pageInventory.table.identifyLed'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500181 formatter: this.dataFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500182 },
Yoshie Muranaka130b1b62020-06-18 14:29:57 -0700183 ],
SurenNewareba91c492020-10-27 14:18:54 +0530184 searchFilter: searchFilter,
Derick Montague602e98a2020-10-21 16:20:00 -0500185 searchTotalFilteredRows: 0,
SurenNewareba91c492020-10-27 14:18:54 +0530186 expandRowLabel: expandRowLabel,
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700187 };
188 },
189 computed: {
Sukanya Pandey99010962020-07-27 21:44:47 +0530190 filteredRows() {
191 return this.searchFilter
192 ? this.searchTotalFilteredRows
193 : this.powerSupplies.length;
194 },
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700195 powerSupplies() {
196 return this.$store.getters['powerSupply/powerSupplies'];
Derick Montague602e98a2020-10-21 16:20:00 -0500197 },
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700198 },
199 created() {
MichalX Szopinskidca9b0a2021-05-07 13:14:50 +0200200 this.$store.dispatch('powerSupply/getAllPowerSupplies').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500201 // Emit initial data fetch complete to parent component
Sukanya Pandeyedb8a772020-10-29 11:33:42 +0530202 this.$root.$emit('hardware-status-power-supplies-complete');
Kenneth Fullbright41057852021-12-27 16:19:37 -0600203 this.isBusy = false;
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700204 });
205 },
206 methods: {
207 sortCompare(a, b, key) {
208 if (key === 'health') {
209 return this.sortStatus(a, b, key);
210 }
Yoshie Muranaka130b1b62020-06-18 14:29:57 -0700211 },
Sukanya Pandey99010962020-07-27 21:44:47 +0530212 onFiltered(filteredItems) {
213 this.searchTotalFilteredRows = filteredItems.length;
Derick Montague602e98a2020-10-21 16:20:00 -0500214 },
215 },
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700216};
217</script>