blob: 4d57feca9dac6086e987289a824eaf40dc5dece9 [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
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 -->
34 <template v-slot:cell(expandRow)="row">
Dixsie Wolmers83133762020-07-15 08:45:19 -050035 <b-button
36 variant="link"
37 data-test-id="hardwareStatus-button-expandPowerSupplies"
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050038 :aria-label="expandRowLabel"
39 @click="toggleRowDetails(row)"
Dixsie Wolmers83133762020-07-15 08:45:19 -050040 >
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050041 <icon-chevron :title="expandRowLabel" />
Yoshie Muranaka5918b482020-06-08 08:18:23 -070042 </b-button>
43 </template>
44
45 <!-- Health -->
46 <template v-slot:cell(health)="{ value }">
47 <status-icon :status="statusIcon(value)" />
48 {{ value }}
49 </template>
50
51 <template v-slot:row-details="{ item }">
52 <b-container fluid>
53 <b-row>
54 <b-col sm="6" xl="4">
55 <dl>
56 <!-- Efficiency percent -->
57 <dt>{{ $t('pageHardwareStatus.table.efficiencyPercent') }}:</dt>
58 <dd>{{ tableFormatter(item.efficiencyPercent) }}</dd>
59 <br />
60 <!-- Firmware version -->
61 <dt>{{ $t('pageHardwareStatus.table.firmwareVersion') }}:</dt>
62 <dd>{{ tableFormatter(item.firmwareVersion) }}</dd>
63 <br />
64 <!-- Indicator LED -->
65 <dt>{{ $t('pageHardwareStatus.table.indicatorLed') }}:</dt>
66 <dd>{{ tableFormatter(item.indicatorLed) }}</dd>
67 </dl>
68 </b-col>
69 <b-col sm="6" xl="4">
70 <dl>
71 <!-- Model -->
72 <dt>{{ $t('pageHardwareStatus.table.model') }}:</dt>
73 <dd>{{ tableFormatter(item.model) }}</dd>
74 <br />
75 <!-- Power input watts -->
76 <dt>{{ $t('pageHardwareStatus.table.powerInputWatts') }}:</dt>
77 <dd>{{ tableFormatter(item.powerInputWatts) }}</dd>
78 <br />
79 <!-- Status state -->
80 <dt>{{ $t('pageHardwareStatus.table.statusState') }}:</dt>
81 <dd>{{ tableFormatter(item.statusState) }}</dd>
82 </dl>
83 </b-col>
84 </b-row>
85 </b-container>
86 </template>
87 </b-table>
88 </page-section>
89</template>
90
91<script>
92import PageSection from '@/components/Global/PageSection';
93import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
94
95import StatusIcon from '@/components/Global/StatusIcon';
Sukanya Pandey99010962020-07-27 21:44:47 +053096import TableCellCount from '@/components/Global/TableCellCount';
Yoshie Muranaka386df452020-06-18 12:45:13 -070097import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin';
Yoshie Muranaka5918b482020-06-08 08:18:23 -070098import TableSortMixin from '@/components/Mixins/TableSortMixin';
Yoshie Muranaka130b1b62020-06-18 14:29:57 -070099import Search from '@/components/Global/Search';
Dixsie Wolmers9b22b492020-09-07 21:26:06 -0500100import SearchFilterMixin from '@/components/Mixins/SearchFilterMixin';
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500101import TableRowExpandMixin from '@/components/Mixins/TableRowExpandMixin';
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700102
103export default {
Sukanya Pandey99010962020-07-27 21:44:47 +0530104 components: { IconChevron, PageSection, StatusIcon, Search, TableCellCount },
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500105 mixins: [
106 TableRowExpandMixin,
107 TableDataFormatterMixin,
108 TableSortMixin,
109 SearchFilterMixin
110 ],
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700111 data() {
112 return {
113 fields: [
114 {
115 key: 'expandRow',
116 label: '',
117 tdClass: 'table-row-expand',
118 sortable: false
119 },
120 {
121 key: 'id',
122 label: this.$t('pageHardwareStatus.table.id'),
123 formatter: this.tableFormatter,
124 sortable: true
125 },
126 {
127 key: 'health',
128 label: this.$t('pageHardwareStatus.table.health'),
129 formatter: this.tableFormatter,
130 sortable: true
131 },
132 {
133 key: 'partNumber',
134 label: this.$t('pageHardwareStatus.table.partNumber'),
135 formatter: this.tableFormatter,
136 sortable: true
137 },
138 {
139 key: 'serialNumber',
140 label: this.$t('pageHardwareStatus.table.serialNumber'),
141 formatter: this.tableFormatter,
142 sortable: true
143 }
Yoshie Muranaka130b1b62020-06-18 14:29:57 -0700144 ],
Sukanya Pandey99010962020-07-27 21:44:47 +0530145 searchTotalFilteredRows: 0
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700146 };
147 },
148 computed: {
Sukanya Pandey99010962020-07-27 21:44:47 +0530149 filteredRows() {
150 return this.searchFilter
151 ? this.searchTotalFilteredRows
152 : this.powerSupplies.length;
153 },
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700154 powerSupplies() {
155 return this.$store.getters['powerSupply/powerSupplies'];
156 }
157 },
158 created() {
159 this.$store.dispatch('powerSupply/getPowerSupply').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500160 // Emit initial data fetch complete to parent component
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700161 this.$root.$emit('hardwareStatus::powerSupplies::complete');
162 });
163 },
164 methods: {
165 sortCompare(a, b, key) {
166 if (key === 'health') {
167 return this.sortStatus(a, b, key);
168 }
Yoshie Muranaka130b1b62020-06-18 14:29:57 -0700169 },
Sukanya Pandey99010962020-07-27 21:44:47 +0530170 onFiltered(filteredItems) {
171 this.searchTotalFilteredRows = filteredItems.length;
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700172 }
173 }
174};
175</script>