blob: 51b579ed35a2af02c6bbeb751a31d6f353c4edc4 [file] [log] [blame]
Yoshie Muranaka5918b482020-06-08 08:18:23 -07001<template>
2 <page-section :section-title="$t('pageHardwareStatus.powerSupplies')">
Yoshie Muranaka130b1b62020-06-18 14:29:57 -07003 <b-row>
4 <b-col sm="6" md="5" xl="4">
Dixsie Wolmers9b22b492020-09-07 21:26:06 -05005 <search
6 @changeSearch="onChangeSearchInput"
7 @clearSearch="onClearSearchInput"
8 />
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
SurenNeware5e25e282020-07-08 15:57:23 +053020 responsive="md"
Yoshie Muranaka5918b482020-06-08 08:18:23 -070021 sort-by="health"
SurenNeware307382e2020-07-27 20:45:14 +053022 show-empty
Yoshie Muranaka5918b482020-06-08 08:18:23 -070023 :items="powerSupplies"
24 :fields="fields"
25 :sort-desc="true"
26 :sort-compare="sortCompare"
Yoshie Muranaka130b1b62020-06-18 14:29:57 -070027 :filter="searchFilter"
SurenNeware307382e2020-07-27 20:45:14 +053028 :empty-text="$t('global.table.emptyMessage')"
SurenNeware156a0e62020-08-28 19:20:03 +053029 :empty-filtered-text="$t('global.table.emptySearchMessage')"
Sukanya Pandey99010962020-07-27 21:44:47 +053030 @filtered="onFiltered"
Yoshie Muranaka5918b482020-06-08 08:18:23 -070031 >
32 <!-- Expand chevron icon -->
33 <template v-slot:cell(expandRow)="row">
Dixsie Wolmers83133762020-07-15 08:45:19 -050034 <b-button
35 variant="link"
36 data-test-id="hardwareStatus-button-expandPowerSupplies"
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050037 :aria-label="expandRowLabel"
38 @click="toggleRowDetails(row)"
Dixsie Wolmers83133762020-07-15 08:45:19 -050039 >
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050040 <icon-chevron :title="expandRowLabel" />
Yoshie Muranaka5918b482020-06-08 08:18:23 -070041 </b-button>
42 </template>
43
44 <!-- Health -->
45 <template v-slot:cell(health)="{ value }">
46 <status-icon :status="statusIcon(value)" />
47 {{ value }}
48 </template>
49
50 <template v-slot:row-details="{ item }">
51 <b-container fluid>
52 <b-row>
53 <b-col sm="6" xl="4">
54 <dl>
55 <!-- Efficiency percent -->
56 <dt>{{ $t('pageHardwareStatus.table.efficiencyPercent') }}:</dt>
57 <dd>{{ tableFormatter(item.efficiencyPercent) }}</dd>
58 <br />
59 <!-- Firmware version -->
60 <dt>{{ $t('pageHardwareStatus.table.firmwareVersion') }}:</dt>
61 <dd>{{ tableFormatter(item.firmwareVersion) }}</dd>
62 <br />
63 <!-- Indicator LED -->
64 <dt>{{ $t('pageHardwareStatus.table.indicatorLed') }}:</dt>
65 <dd>{{ tableFormatter(item.indicatorLed) }}</dd>
66 </dl>
67 </b-col>
68 <b-col sm="6" xl="4">
69 <dl>
70 <!-- Model -->
71 <dt>{{ $t('pageHardwareStatus.table.model') }}:</dt>
72 <dd>{{ tableFormatter(item.model) }}</dd>
73 <br />
74 <!-- Power input watts -->
75 <dt>{{ $t('pageHardwareStatus.table.powerInputWatts') }}:</dt>
76 <dd>{{ tableFormatter(item.powerInputWatts) }}</dd>
77 <br />
78 <!-- Status state -->
79 <dt>{{ $t('pageHardwareStatus.table.statusState') }}:</dt>
80 <dd>{{ tableFormatter(item.statusState) }}</dd>
81 </dl>
82 </b-col>
83 </b-row>
84 </b-container>
85 </template>
86 </b-table>
87 </page-section>
88</template>
89
90<script>
91import PageSection from '@/components/Global/PageSection';
92import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
93
94import StatusIcon from '@/components/Global/StatusIcon';
Sukanya Pandey99010962020-07-27 21:44:47 +053095import TableCellCount from '@/components/Global/TableCellCount';
Yoshie Muranaka386df452020-06-18 12:45:13 -070096import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin';
Yoshie Muranaka5918b482020-06-08 08:18:23 -070097import TableSortMixin from '@/components/Mixins/TableSortMixin';
Yoshie Muranaka130b1b62020-06-18 14:29:57 -070098import Search from '@/components/Global/Search';
Dixsie Wolmers9b22b492020-09-07 21:26:06 -050099import SearchFilterMixin from '@/components/Mixins/SearchFilterMixin';
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500100import TableRowExpandMixin from '@/components/Mixins/TableRowExpandMixin';
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700101
102export default {
Sukanya Pandey99010962020-07-27 21:44:47 +0530103 components: { IconChevron, PageSection, StatusIcon, Search, TableCellCount },
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500104 mixins: [
105 TableRowExpandMixin,
106 TableDataFormatterMixin,
107 TableSortMixin,
108 SearchFilterMixin
109 ],
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700110 data() {
111 return {
112 fields: [
113 {
114 key: 'expandRow',
115 label: '',
116 tdClass: 'table-row-expand',
117 sortable: false
118 },
119 {
120 key: 'id',
121 label: this.$t('pageHardwareStatus.table.id'),
122 formatter: this.tableFormatter,
123 sortable: true
124 },
125 {
126 key: 'health',
127 label: this.$t('pageHardwareStatus.table.health'),
128 formatter: this.tableFormatter,
129 sortable: true
130 },
131 {
132 key: 'partNumber',
133 label: this.$t('pageHardwareStatus.table.partNumber'),
134 formatter: this.tableFormatter,
135 sortable: true
136 },
137 {
138 key: 'serialNumber',
139 label: this.$t('pageHardwareStatus.table.serialNumber'),
140 formatter: this.tableFormatter,
141 sortable: true
142 }
Yoshie Muranaka130b1b62020-06-18 14:29:57 -0700143 ],
Sukanya Pandey99010962020-07-27 21:44:47 +0530144 searchTotalFilteredRows: 0
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700145 };
146 },
147 computed: {
Sukanya Pandey99010962020-07-27 21:44:47 +0530148 filteredRows() {
149 return this.searchFilter
150 ? this.searchTotalFilteredRows
151 : this.powerSupplies.length;
152 },
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700153 powerSupplies() {
154 return this.$store.getters['powerSupply/powerSupplies'];
155 }
156 },
157 created() {
158 this.$store.dispatch('powerSupply/getPowerSupply').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500159 // Emit initial data fetch complete to parent component
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700160 this.$root.$emit('hardwareStatus::powerSupplies::complete');
161 });
162 },
163 methods: {
164 sortCompare(a, b, key) {
165 if (key === 'health') {
166 return this.sortStatus(a, b, key);
167 }
Yoshie Muranaka130b1b62020-06-18 14:29:57 -0700168 },
Sukanya Pandey99010962020-07-27 21:44:47 +0530169 onFiltered(filteredItems) {
170 this.searchTotalFilteredRows = filteredItems.length;
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700171 }
172 }
173};
174</script>