blob: 77a1e3c8665a5f9cf562453349f2602c40ff59b4 [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">
5 <search @changeSearch="onChangeSearchInput" />
6 </b-col>
Sukanya Pandey99010962020-07-27 21:44:47 +05307 <b-col sm="6" md="3" xl="2">
8 <table-cell-count
9 :filtered-items-count="filteredRows"
10 :total-number-of-cells="powerSupplies.length"
11 ></table-cell-count>
12 </b-col>
Yoshie Muranaka130b1b62020-06-18 14:29:57 -070013 </b-row>
Yoshie Muranaka5918b482020-06-08 08:18:23 -070014 <b-table
15 sort-icon-left
16 no-sort-reset
SurenNeware5e25e282020-07-08 15:57:23 +053017 responsive="md"
Yoshie Muranaka5918b482020-06-08 08:18:23 -070018 sort-by="health"
SurenNeware307382e2020-07-27 20:45:14 +053019 show-empty
Yoshie Muranaka5918b482020-06-08 08:18:23 -070020 :items="powerSupplies"
21 :fields="fields"
22 :sort-desc="true"
23 :sort-compare="sortCompare"
Yoshie Muranaka130b1b62020-06-18 14:29:57 -070024 :filter="searchFilter"
SurenNeware307382e2020-07-27 20:45:14 +053025 :empty-text="$t('global.table.emptyMessage')"
SurenNeware156a0e62020-08-28 19:20:03 +053026 :empty-filtered-text="$t('global.table.emptySearchMessage')"
Sukanya Pandey99010962020-07-27 21:44:47 +053027 @filtered="onFiltered"
Yoshie Muranaka5918b482020-06-08 08:18:23 -070028 >
29 <!-- Expand chevron icon -->
30 <template v-slot:cell(expandRow)="row">
Dixsie Wolmers83133762020-07-15 08:45:19 -050031 <b-button
32 variant="link"
33 data-test-id="hardwareStatus-button-expandPowerSupplies"
34 @click="row.toggleDetails"
35 >
Yoshie Muranaka5918b482020-06-08 08:18:23 -070036 <icon-chevron />
37 </b-button>
38 </template>
39
40 <!-- Health -->
41 <template v-slot:cell(health)="{ value }">
42 <status-icon :status="statusIcon(value)" />
43 {{ value }}
44 </template>
45
46 <template v-slot:row-details="{ item }">
47 <b-container fluid>
48 <b-row>
49 <b-col sm="6" xl="4">
50 <dl>
51 <!-- Efficiency percent -->
52 <dt>{{ $t('pageHardwareStatus.table.efficiencyPercent') }}:</dt>
53 <dd>{{ tableFormatter(item.efficiencyPercent) }}</dd>
54 <br />
55 <!-- Firmware version -->
56 <dt>{{ $t('pageHardwareStatus.table.firmwareVersion') }}:</dt>
57 <dd>{{ tableFormatter(item.firmwareVersion) }}</dd>
58 <br />
59 <!-- Indicator LED -->
60 <dt>{{ $t('pageHardwareStatus.table.indicatorLed') }}:</dt>
61 <dd>{{ tableFormatter(item.indicatorLed) }}</dd>
62 </dl>
63 </b-col>
64 <b-col sm="6" xl="4">
65 <dl>
66 <!-- Model -->
67 <dt>{{ $t('pageHardwareStatus.table.model') }}:</dt>
68 <dd>{{ tableFormatter(item.model) }}</dd>
69 <br />
70 <!-- Power input watts -->
71 <dt>{{ $t('pageHardwareStatus.table.powerInputWatts') }}:</dt>
72 <dd>{{ tableFormatter(item.powerInputWatts) }}</dd>
73 <br />
74 <!-- Status state -->
75 <dt>{{ $t('pageHardwareStatus.table.statusState') }}:</dt>
76 <dd>{{ tableFormatter(item.statusState) }}</dd>
77 </dl>
78 </b-col>
79 </b-row>
80 </b-container>
81 </template>
82 </b-table>
83 </page-section>
84</template>
85
86<script>
87import PageSection from '@/components/Global/PageSection';
88import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
89
90import StatusIcon from '@/components/Global/StatusIcon';
Sukanya Pandey99010962020-07-27 21:44:47 +053091import TableCellCount from '@/components/Global/TableCellCount';
Yoshie Muranaka386df452020-06-18 12:45:13 -070092import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin';
Yoshie Muranaka5918b482020-06-08 08:18:23 -070093import TableSortMixin from '@/components/Mixins/TableSortMixin';
Yoshie Muranaka130b1b62020-06-18 14:29:57 -070094import Search from '@/components/Global/Search';
Yoshie Muranaka5918b482020-06-08 08:18:23 -070095
96export default {
Sukanya Pandey99010962020-07-27 21:44:47 +053097 components: { IconChevron, PageSection, StatusIcon, Search, TableCellCount },
Yoshie Muranaka386df452020-06-18 12:45:13 -070098 mixins: [TableDataFormatterMixin, TableSortMixin],
Yoshie Muranaka5918b482020-06-08 08:18:23 -070099 data() {
100 return {
101 fields: [
102 {
103 key: 'expandRow',
104 label: '',
105 tdClass: 'table-row-expand',
106 sortable: false
107 },
108 {
109 key: 'id',
110 label: this.$t('pageHardwareStatus.table.id'),
111 formatter: this.tableFormatter,
112 sortable: true
113 },
114 {
115 key: 'health',
116 label: this.$t('pageHardwareStatus.table.health'),
117 formatter: this.tableFormatter,
118 sortable: true
119 },
120 {
121 key: 'partNumber',
122 label: this.$t('pageHardwareStatus.table.partNumber'),
123 formatter: this.tableFormatter,
124 sortable: true
125 },
126 {
127 key: 'serialNumber',
128 label: this.$t('pageHardwareStatus.table.serialNumber'),
129 formatter: this.tableFormatter,
130 sortable: true
131 }
Yoshie Muranaka130b1b62020-06-18 14:29:57 -0700132 ],
Sukanya Pandey99010962020-07-27 21:44:47 +0530133 searchFilter: null,
134 searchTotalFilteredRows: 0
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700135 };
136 },
137 computed: {
Sukanya Pandey99010962020-07-27 21:44:47 +0530138 filteredRows() {
139 return this.searchFilter
140 ? this.searchTotalFilteredRows
141 : this.powerSupplies.length;
142 },
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700143 powerSupplies() {
144 return this.$store.getters['powerSupply/powerSupplies'];
145 }
146 },
147 created() {
148 this.$store.dispatch('powerSupply/getPowerSupply').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500149 // Emit initial data fetch complete to parent component
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700150 this.$root.$emit('hardwareStatus::powerSupplies::complete');
151 });
152 },
153 methods: {
154 sortCompare(a, b, key) {
155 if (key === 'health') {
156 return this.sortStatus(a, b, key);
157 }
Yoshie Muranaka130b1b62020-06-18 14:29:57 -0700158 },
159 onChangeSearchInput(searchValue) {
160 this.searchFilter = searchValue;
Sukanya Pandey99010962020-07-27 21:44:47 +0530161 },
162 onFiltered(filteredItems) {
163 this.searchTotalFilteredRows = filteredItems.length;
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700164 }
165 }
166};
167</script>