blob: 0eb2f608d457c9cccdaaff2e4f223537c48520da [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"
37 @click="row.toggleDetails"
38 >
Yoshie Muranaka5918b482020-06-08 08:18:23 -070039 <icon-chevron />
40 </b-button>
41 </template>
42
43 <!-- Health -->
44 <template v-slot:cell(health)="{ value }">
45 <status-icon :status="statusIcon(value)" />
46 {{ value }}
47 </template>
48
49 <template v-slot:row-details="{ item }">
50 <b-container fluid>
51 <b-row>
52 <b-col sm="6" xl="4">
53 <dl>
54 <!-- Efficiency percent -->
55 <dt>{{ $t('pageHardwareStatus.table.efficiencyPercent') }}:</dt>
56 <dd>{{ tableFormatter(item.efficiencyPercent) }}</dd>
57 <br />
58 <!-- Firmware version -->
59 <dt>{{ $t('pageHardwareStatus.table.firmwareVersion') }}:</dt>
60 <dd>{{ tableFormatter(item.firmwareVersion) }}</dd>
61 <br />
62 <!-- Indicator LED -->
63 <dt>{{ $t('pageHardwareStatus.table.indicatorLed') }}:</dt>
64 <dd>{{ tableFormatter(item.indicatorLed) }}</dd>
65 </dl>
66 </b-col>
67 <b-col sm="6" xl="4">
68 <dl>
69 <!-- Model -->
70 <dt>{{ $t('pageHardwareStatus.table.model') }}:</dt>
71 <dd>{{ tableFormatter(item.model) }}</dd>
72 <br />
73 <!-- Power input watts -->
74 <dt>{{ $t('pageHardwareStatus.table.powerInputWatts') }}:</dt>
75 <dd>{{ tableFormatter(item.powerInputWatts) }}</dd>
76 <br />
77 <!-- Status state -->
78 <dt>{{ $t('pageHardwareStatus.table.statusState') }}:</dt>
79 <dd>{{ tableFormatter(item.statusState) }}</dd>
80 </dl>
81 </b-col>
82 </b-row>
83 </b-container>
84 </template>
85 </b-table>
86 </page-section>
87</template>
88
89<script>
90import PageSection from '@/components/Global/PageSection';
91import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
92
93import StatusIcon from '@/components/Global/StatusIcon';
Sukanya Pandey99010962020-07-27 21:44:47 +053094import TableCellCount from '@/components/Global/TableCellCount';
Yoshie Muranaka386df452020-06-18 12:45:13 -070095import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin';
Yoshie Muranaka5918b482020-06-08 08:18:23 -070096import TableSortMixin from '@/components/Mixins/TableSortMixin';
Yoshie Muranaka130b1b62020-06-18 14:29:57 -070097import Search from '@/components/Global/Search';
Dixsie Wolmers9b22b492020-09-07 21:26:06 -050098import SearchFilterMixin from '@/components/Mixins/SearchFilterMixin';
Yoshie Muranaka5918b482020-06-08 08:18:23 -070099
100export default {
Sukanya Pandey99010962020-07-27 21:44:47 +0530101 components: { IconChevron, PageSection, StatusIcon, Search, TableCellCount },
Dixsie Wolmers9b22b492020-09-07 21:26:06 -0500102 mixins: [TableDataFormatterMixin, TableSortMixin, SearchFilterMixin],
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700103 data() {
104 return {
105 fields: [
106 {
107 key: 'expandRow',
108 label: '',
109 tdClass: 'table-row-expand',
110 sortable: false
111 },
112 {
113 key: 'id',
114 label: this.$t('pageHardwareStatus.table.id'),
115 formatter: this.tableFormatter,
116 sortable: true
117 },
118 {
119 key: 'health',
120 label: this.$t('pageHardwareStatus.table.health'),
121 formatter: this.tableFormatter,
122 sortable: true
123 },
124 {
125 key: 'partNumber',
126 label: this.$t('pageHardwareStatus.table.partNumber'),
127 formatter: this.tableFormatter,
128 sortable: true
129 },
130 {
131 key: 'serialNumber',
132 label: this.$t('pageHardwareStatus.table.serialNumber'),
133 formatter: this.tableFormatter,
134 sortable: true
135 }
Yoshie Muranaka130b1b62020-06-18 14:29:57 -0700136 ],
Sukanya Pandey99010962020-07-27 21:44:47 +0530137 searchTotalFilteredRows: 0
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700138 };
139 },
140 computed: {
Sukanya Pandey99010962020-07-27 21:44:47 +0530141 filteredRows() {
142 return this.searchFilter
143 ? this.searchTotalFilteredRows
144 : this.powerSupplies.length;
145 },
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700146 powerSupplies() {
147 return this.$store.getters['powerSupply/powerSupplies'];
148 }
149 },
150 created() {
151 this.$store.dispatch('powerSupply/getPowerSupply').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500152 // Emit initial data fetch complete to parent component
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700153 this.$root.$emit('hardwareStatus::powerSupplies::complete');
154 });
155 },
156 methods: {
157 sortCompare(a, b, key) {
158 if (key === 'health') {
159 return this.sortStatus(a, b, key);
160 }
Yoshie Muranaka130b1b62020-06-18 14:29:57 -0700161 },
Sukanya Pandey99010962020-07-27 21:44:47 +0530162 onFiltered(filteredItems) {
163 this.searchTotalFilteredRows = filteredItems.length;
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700164 }
165 }
166};
167</script>