blob: 3de69198c6361874c17038d398ee2b89b59ceb23 [file] [log] [blame]
Yoshie Muranaka5918b482020-06-08 08:18:23 -07001<template>
2 <page-section :section-title="$t('pageHardwareStatus.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>
58 <!-- Efficiency percent -->
59 <dt>{{ $t('pageHardwareStatus.table.efficiencyPercent') }}:</dt>
60 <dd>{{ tableFormatter(item.efficiencyPercent) }}</dd>
61 <br />
62 <!-- Firmware version -->
63 <dt>{{ $t('pageHardwareStatus.table.firmwareVersion') }}:</dt>
64 <dd>{{ tableFormatter(item.firmwareVersion) }}</dd>
65 <br />
66 <!-- Indicator LED -->
67 <dt>{{ $t('pageHardwareStatus.table.indicatorLed') }}:</dt>
68 <dd>{{ tableFormatter(item.indicatorLed) }}</dd>
69 </dl>
70 </b-col>
71 <b-col sm="6" xl="4">
72 <dl>
73 <!-- Model -->
74 <dt>{{ $t('pageHardwareStatus.table.model') }}:</dt>
75 <dd>{{ tableFormatter(item.model) }}</dd>
76 <br />
77 <!-- Power input watts -->
78 <dt>{{ $t('pageHardwareStatus.table.powerInputWatts') }}:</dt>
79 <dd>{{ tableFormatter(item.powerInputWatts) }}</dd>
80 <br />
81 <!-- Status state -->
82 <dt>{{ $t('pageHardwareStatus.table.statusState') }}:</dt>
83 <dd>{{ tableFormatter(item.statusState) }}</dd>
84 </dl>
85 </b-col>
86 </b-row>
87 </b-container>
88 </template>
89 </b-table>
90 </page-section>
91</template>
92
93<script>
94import PageSection from '@/components/Global/PageSection';
95import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
96
97import StatusIcon from '@/components/Global/StatusIcon';
Sukanya Pandey99010962020-07-27 21:44:47 +053098import TableCellCount from '@/components/Global/TableCellCount';
Yoshie Muranaka386df452020-06-18 12:45:13 -070099import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin';
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700100import TableSortMixin from '@/components/Mixins/TableSortMixin';
Yoshie Muranaka130b1b62020-06-18 14:29:57 -0700101import Search from '@/components/Global/Search';
SurenNewareba91c492020-10-27 14:18:54 +0530102import SearchFilterMixin, {
103 searchFilter,
104} from '@/components/Mixins/SearchFilterMixin';
105import TableRowExpandMixin, {
106 expandRowLabel,
107} from '@/components/Mixins/TableRowExpandMixin';
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700108
109export default {
Sukanya Pandey99010962020-07-27 21:44:47 +0530110 components: { IconChevron, PageSection, StatusIcon, Search, TableCellCount },
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500111 mixins: [
112 TableRowExpandMixin,
113 TableDataFormatterMixin,
114 TableSortMixin,
Derick Montague602e98a2020-10-21 16:20:00 -0500115 SearchFilterMixin,
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500116 ],
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700117 data() {
118 return {
119 fields: [
120 {
121 key: 'expandRow',
122 label: '',
123 tdClass: 'table-row-expand',
Derick Montague602e98a2020-10-21 16:20:00 -0500124 sortable: false,
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700125 },
126 {
127 key: 'id',
128 label: this.$t('pageHardwareStatus.table.id'),
129 formatter: this.tableFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500130 sortable: true,
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700131 },
132 {
133 key: 'health',
134 label: this.$t('pageHardwareStatus.table.health'),
135 formatter: this.tableFormatter,
Dixsie Wolmersa04d46f2020-10-22 06:34:56 -0500136 sortable: true,
Derick Montague602e98a2020-10-21 16:20:00 -0500137 tdClass: 'text-nowrap',
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700138 },
139 {
140 key: 'partNumber',
141 label: this.$t('pageHardwareStatus.table.partNumber'),
142 formatter: this.tableFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500143 sortable: true,
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700144 },
145 {
146 key: 'serialNumber',
147 label: this.$t('pageHardwareStatus.table.serialNumber'),
148 formatter: this.tableFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500149 sortable: true,
150 },
Yoshie Muranaka130b1b62020-06-18 14:29:57 -0700151 ],
SurenNewareba91c492020-10-27 14:18:54 +0530152 searchFilter: searchFilter,
Derick Montague602e98a2020-10-21 16:20:00 -0500153 searchTotalFilteredRows: 0,
SurenNewareba91c492020-10-27 14:18:54 +0530154 expandRowLabel: expandRowLabel,
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700155 };
156 },
157 computed: {
Sukanya Pandey99010962020-07-27 21:44:47 +0530158 filteredRows() {
159 return this.searchFilter
160 ? this.searchTotalFilteredRows
161 : this.powerSupplies.length;
162 },
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700163 powerSupplies() {
164 return this.$store.getters['powerSupply/powerSupplies'];
Derick Montague602e98a2020-10-21 16:20:00 -0500165 },
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700166 },
167 created() {
168 this.$store.dispatch('powerSupply/getPowerSupply').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500169 // Emit initial data fetch complete to parent component
Sukanya Pandeyedb8a772020-10-29 11:33:42 +0530170 this.$root.$emit('hardware-status-power-supplies-complete');
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700171 });
172 },
173 methods: {
174 sortCompare(a, b, key) {
175 if (key === 'health') {
176 return this.sortStatus(a, b, key);
177 }
Yoshie Muranaka130b1b62020-06-18 14:29:57 -0700178 },
Sukanya Pandey99010962020-07-27 21:44:47 +0530179 onFiltered(filteredItems) {
180 this.searchTotalFilteredRows = filteredItems.length;
Derick Montague602e98a2020-10-21 16:20:00 -0500181 },
182 },
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700183};
184</script>