blob: 94f5774bdedab09b07b66a1f64d09c81e8e65a65 [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
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 Wolmersb53e0862020-09-08 14:13:38 -050038 :aria-label="expandRowLabel"
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 />
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';
Dixsie Wolmers9b22b492020-09-07 21:26:06 -0500102import SearchFilterMixin from '@/components/Mixins/SearchFilterMixin';
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500103import TableRowExpandMixin from '@/components/Mixins/TableRowExpandMixin';
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700104
105export default {
Sukanya Pandey99010962020-07-27 21:44:47 +0530106 components: { IconChevron, PageSection, StatusIcon, Search, TableCellCount },
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500107 mixins: [
108 TableRowExpandMixin,
109 TableDataFormatterMixin,
110 TableSortMixin,
Derick Montague602e98a2020-10-21 16:20:00 -0500111 SearchFilterMixin,
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500112 ],
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700113 data() {
114 return {
115 fields: [
116 {
117 key: 'expandRow',
118 label: '',
119 tdClass: 'table-row-expand',
Derick Montague602e98a2020-10-21 16:20:00 -0500120 sortable: false,
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700121 },
122 {
123 key: 'id',
124 label: this.$t('pageHardwareStatus.table.id'),
125 formatter: this.tableFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500126 sortable: true,
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700127 },
128 {
129 key: 'health',
130 label: this.$t('pageHardwareStatus.table.health'),
131 formatter: this.tableFormatter,
Dixsie Wolmersa04d46f2020-10-22 06:34:56 -0500132 sortable: true,
Derick Montague602e98a2020-10-21 16:20:00 -0500133 tdClass: 'text-nowrap',
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700134 },
135 {
136 key: 'partNumber',
137 label: this.$t('pageHardwareStatus.table.partNumber'),
138 formatter: this.tableFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500139 sortable: true,
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700140 },
141 {
142 key: 'serialNumber',
143 label: this.$t('pageHardwareStatus.table.serialNumber'),
144 formatter: this.tableFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500145 sortable: true,
146 },
Yoshie Muranaka130b1b62020-06-18 14:29:57 -0700147 ],
Derick Montague602e98a2020-10-21 16:20:00 -0500148 searchTotalFilteredRows: 0,
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700149 };
150 },
151 computed: {
Sukanya Pandey99010962020-07-27 21:44:47 +0530152 filteredRows() {
153 return this.searchFilter
154 ? this.searchTotalFilteredRows
155 : this.powerSupplies.length;
156 },
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700157 powerSupplies() {
158 return this.$store.getters['powerSupply/powerSupplies'];
Derick Montague602e98a2020-10-21 16:20:00 -0500159 },
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700160 },
161 created() {
162 this.$store.dispatch('powerSupply/getPowerSupply').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500163 // Emit initial data fetch complete to parent component
Sukanya Pandeyedb8a772020-10-29 11:33:42 +0530164 this.$root.$emit('hardware-status-power-supplies-complete');
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700165 });
166 },
167 methods: {
168 sortCompare(a, b, key) {
169 if (key === 'health') {
170 return this.sortStatus(a, b, key);
171 }
Yoshie Muranaka130b1b62020-06-18 14:29:57 -0700172 },
Sukanya Pandey99010962020-07-27 21:44:47 +0530173 onFiltered(filteredItems) {
174 this.searchTotalFilteredRows = filteredItems.length;
Derick Montague602e98a2020-10-21 16:20:00 -0500175 },
176 },
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700177};
178</script>