blob: ba0896bf4de0d1d18b15694307fae7be037f74c6 [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')"
Sukanya Pandey99010962020-07-27 21:44:47 +053031 @filtered="onFiltered"
Yoshie Muranaka5918b482020-06-08 08:18:23 -070032 >
33 <!-- Expand chevron icon -->
Derick Montague602e98a2020-10-21 16:20:00 -050034 <template #cell(expandRow)="row">
Dixsie Wolmers83133762020-07-15 08:45:19 -050035 <b-button
36 variant="link"
37 data-test-id="hardwareStatus-button-expandPowerSupplies"
Dixsie Wolmers30f11f82020-11-10 16:07:56 -060038 :title="expandRowLabel"
39 class="btn-icon-only"
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050040 @click="toggleRowDetails(row)"
Dixsie Wolmers83133762020-07-15 08:45:19 -050041 >
Dixsie Wolmers30f11f82020-11-10 16:07:56 -060042 <icon-chevron />
SurenNeware6e2cb972020-12-24 20:58:16 +053043 <span class="sr-only">{{ expandRowLabel }}</span>
Yoshie Muranaka5918b482020-06-08 08:18:23 -070044 </b-button>
45 </template>
46
47 <!-- Health -->
Derick Montague602e98a2020-10-21 16:20:00 -050048 <template #cell(health)="{ value }">
Yoshie Muranaka5918b482020-06-08 08:18:23 -070049 <status-icon :status="statusIcon(value)" />
50 {{ value }}
51 </template>
52
Derick Montague602e98a2020-10-21 16:20:00 -050053 <template #row-details="{ item }">
Yoshie Muranaka5918b482020-06-08 08:18:23 -070054 <b-container fluid>
55 <b-row>
56 <b-col sm="6" xl="4">
57 <dl>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -050058 <!-- Name -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053059 <dt>{{ $t('pageInventory.table.name') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050060 <dd>{{ dataFormatter(item.name) }}</dd>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -050061 <!-- Part number -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053062 <dt>{{ $t('pageInventory.table.partNumber') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050063 <dd>{{ dataFormatter(item.partNumber) }}</dd>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -050064 <!-- Serial number -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053065 <dt>{{ $t('pageInventory.table.serialNumber') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050066 <dd>{{ dataFormatter(item.serialNumber) }}</dd>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -050067 <!-- Spare part number -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053068 <dt>{{ $t('pageInventory.table.sparePartNumber') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050069 <dd>{{ dataFormatter(item.sparePartNumber) }}</dd>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -050070 <!-- Model -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053071 <dt>{{ $t('pageInventory.table.model') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050072 <dd>{{ dataFormatter(item.model) }}</dd>
Yoshie Muranaka5918b482020-06-08 08:18:23 -070073 </dl>
74 </b-col>
75 <b-col sm="6" xl="4">
76 <dl>
Yoshie Muranaka5918b482020-06-08 08:18:23 -070077 <!-- Status state -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053078 <dt>{{ $t('pageInventory.table.statusState') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050079 <dd>{{ dataFormatter(item.statusState) }}</dd>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -050080 <!-- Status Health rollup state -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053081 <dt>{{ $t('pageInventory.table.statusHealthRollup') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050082 <dd>{{ dataFormatter(item.statusHealth) }}</dd>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -050083 <!-- Efficiency percent -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053084 <dt>{{ $t('pageInventory.table.efficiencyPercent') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050085 <dd>{{ dataFormatter(item.efficiencyPercent) }}</dd>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -050086 <!-- Power input watts -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053087 <dt>{{ $t('pageInventory.table.powerInputWatts') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050088 <dd>{{ dataFormatter(item.powerInputWatts) }}</dd>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -050089 </dl>
90 </b-col>
91 </b-row>
92 <div class="section-divider mb-3 mt-3"></div>
93 <b-row>
94 <b-col sm="6" xl="4">
95 <dl>
96 <!-- Manufacturer -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053097 <dt>{{ $t('pageInventory.table.manufacturer') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050098 <dd>{{ dataFormatter(item.manufacturer) }}</dd>
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -050099 </dl>
100 </b-col>
101 <b-col sm="6" xl="4">
102 <dl>
103 <!-- Firmware version -->
Sandeepa Singh7affc522021-07-06 16:29:10 +0530104 <dt>{{ $t('pageInventory.table.firmwareVersion') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500105 <dd>{{ dataFormatter(item.firmwareVersion) }}</dd>
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700106 </dl>
107 </b-col>
108 </b-row>
109 </b-container>
110 </template>
111 </b-table>
112 </page-section>
113</template>
114
115<script>
116import PageSection from '@/components/Global/PageSection';
117import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
118
119import StatusIcon from '@/components/Global/StatusIcon';
Sukanya Pandey99010962020-07-27 21:44:47 +0530120import TableCellCount from '@/components/Global/TableCellCount';
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500121import DataFormatterMixin from '@/components/Mixins/DataFormatterMixin';
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700122import TableSortMixin from '@/components/Mixins/TableSortMixin';
Yoshie Muranaka130b1b62020-06-18 14:29:57 -0700123import Search from '@/components/Global/Search';
SurenNewareba91c492020-10-27 14:18:54 +0530124import SearchFilterMixin, {
125 searchFilter,
126} from '@/components/Mixins/SearchFilterMixin';
127import TableRowExpandMixin, {
128 expandRowLabel,
129} from '@/components/Mixins/TableRowExpandMixin';
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700130
131export default {
Sukanya Pandey99010962020-07-27 21:44:47 +0530132 components: { IconChevron, PageSection, StatusIcon, Search, TableCellCount },
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500133 mixins: [
134 TableRowExpandMixin,
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500135 DataFormatterMixin,
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500136 TableSortMixin,
Derick Montague602e98a2020-10-21 16:20:00 -0500137 SearchFilterMixin,
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500138 ],
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700139 data() {
140 return {
141 fields: [
142 {
143 key: 'expandRow',
144 label: '',
145 tdClass: 'table-row-expand',
Derick Montague602e98a2020-10-21 16:20:00 -0500146 sortable: false,
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700147 },
148 {
149 key: 'id',
Sandeepa Singh7affc522021-07-06 16:29:10 +0530150 label: this.$t('pageInventory.table.id'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500151 formatter: this.dataFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500152 sortable: true,
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700153 },
154 {
155 key: 'health',
Sandeepa Singh7affc522021-07-06 16:29:10 +0530156 label: this.$t('pageInventory.table.health'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500157 formatter: this.dataFormatter,
Dixsie Wolmersa04d46f2020-10-22 06:34:56 -0500158 sortable: true,
Derick Montague602e98a2020-10-21 16:20:00 -0500159 tdClass: 'text-nowrap',
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700160 },
161 {
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -0500162 key: 'locationNumber',
Sandeepa Singh7affc522021-07-06 16:29:10 +0530163 label: this.$t('pageInventory.table.locationNumber'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500164 formatter: this.dataFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500165 sortable: true,
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700166 },
167 {
Dixsie Wolmers6b8aee92021-05-14 11:14:33 -0500168 key: 'identifyLed',
Sandeepa Singh7affc522021-07-06 16:29:10 +0530169 label: this.$t('pageInventory.table.identifyLed'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500170 formatter: this.dataFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500171 },
Yoshie Muranaka130b1b62020-06-18 14:29:57 -0700172 ],
SurenNewareba91c492020-10-27 14:18:54 +0530173 searchFilter: searchFilter,
Derick Montague602e98a2020-10-21 16:20:00 -0500174 searchTotalFilteredRows: 0,
SurenNewareba91c492020-10-27 14:18:54 +0530175 expandRowLabel: expandRowLabel,
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700176 };
177 },
178 computed: {
Sukanya Pandey99010962020-07-27 21:44:47 +0530179 filteredRows() {
180 return this.searchFilter
181 ? this.searchTotalFilteredRows
182 : this.powerSupplies.length;
183 },
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700184 powerSupplies() {
185 return this.$store.getters['powerSupply/powerSupplies'];
Derick Montague602e98a2020-10-21 16:20:00 -0500186 },
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700187 },
188 created() {
MichalX Szopinskidca9b0a2021-05-07 13:14:50 +0200189 this.$store.dispatch('powerSupply/getAllPowerSupplies').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500190 // Emit initial data fetch complete to parent component
Sukanya Pandeyedb8a772020-10-29 11:33:42 +0530191 this.$root.$emit('hardware-status-power-supplies-complete');
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700192 });
193 },
194 methods: {
195 sortCompare(a, b, key) {
196 if (key === 'health') {
197 return this.sortStatus(a, b, key);
198 }
Yoshie Muranaka130b1b62020-06-18 14:29:57 -0700199 },
Sukanya Pandey99010962020-07-27 21:44:47 +0530200 onFiltered(filteredItems) {
201 this.searchTotalFilteredRows = filteredItems.length;
Derick Montague602e98a2020-10-21 16:20:00 -0500202 },
203 },
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700204};
205</script>