blob: b6dd326e190718602394f32a2e1ad806a0fa58e2 [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>
7 </b-row>
Yoshie Muranaka5918b482020-06-08 08:18:23 -07008 <b-table
9 sort-icon-left
10 no-sort-reset
SurenNeware5e25e282020-07-08 15:57:23 +053011 responsive="md"
Yoshie Muranaka5918b482020-06-08 08:18:23 -070012 sort-by="health"
13 :items="powerSupplies"
14 :fields="fields"
15 :sort-desc="true"
16 :sort-compare="sortCompare"
Yoshie Muranaka130b1b62020-06-18 14:29:57 -070017 :filter="searchFilter"
Yoshie Muranaka5918b482020-06-08 08:18:23 -070018 >
19 <!-- Expand chevron icon -->
20 <template v-slot:cell(expandRow)="row">
Dixsie Wolmers83133762020-07-15 08:45:19 -050021 <b-button
22 variant="link"
23 data-test-id="hardwareStatus-button-expandPowerSupplies"
24 @click="row.toggleDetails"
25 >
Yoshie Muranaka5918b482020-06-08 08:18:23 -070026 <icon-chevron />
27 </b-button>
28 </template>
29
30 <!-- Health -->
31 <template v-slot:cell(health)="{ value }">
32 <status-icon :status="statusIcon(value)" />
33 {{ value }}
34 </template>
35
36 <template v-slot:row-details="{ item }">
37 <b-container fluid>
38 <b-row>
39 <b-col sm="6" xl="4">
40 <dl>
41 <!-- Efficiency percent -->
42 <dt>{{ $t('pageHardwareStatus.table.efficiencyPercent') }}:</dt>
43 <dd>{{ tableFormatter(item.efficiencyPercent) }}</dd>
44 <br />
45 <!-- Firmware version -->
46 <dt>{{ $t('pageHardwareStatus.table.firmwareVersion') }}:</dt>
47 <dd>{{ tableFormatter(item.firmwareVersion) }}</dd>
48 <br />
49 <!-- Indicator LED -->
50 <dt>{{ $t('pageHardwareStatus.table.indicatorLed') }}:</dt>
51 <dd>{{ tableFormatter(item.indicatorLed) }}</dd>
52 </dl>
53 </b-col>
54 <b-col sm="6" xl="4">
55 <dl>
56 <!-- Model -->
57 <dt>{{ $t('pageHardwareStatus.table.model') }}:</dt>
58 <dd>{{ tableFormatter(item.model) }}</dd>
59 <br />
60 <!-- Power input watts -->
61 <dt>{{ $t('pageHardwareStatus.table.powerInputWatts') }}:</dt>
62 <dd>{{ tableFormatter(item.powerInputWatts) }}</dd>
63 <br />
64 <!-- Status state -->
65 <dt>{{ $t('pageHardwareStatus.table.statusState') }}:</dt>
66 <dd>{{ tableFormatter(item.statusState) }}</dd>
67 </dl>
68 </b-col>
69 </b-row>
70 </b-container>
71 </template>
72 </b-table>
73 </page-section>
74</template>
75
76<script>
77import PageSection from '@/components/Global/PageSection';
78import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
79
80import StatusIcon from '@/components/Global/StatusIcon';
Yoshie Muranaka386df452020-06-18 12:45:13 -070081import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin';
Yoshie Muranaka5918b482020-06-08 08:18:23 -070082import TableSortMixin from '@/components/Mixins/TableSortMixin';
Yoshie Muranaka130b1b62020-06-18 14:29:57 -070083import Search from '@/components/Global/Search';
Yoshie Muranaka5918b482020-06-08 08:18:23 -070084
85export default {
Yoshie Muranaka130b1b62020-06-18 14:29:57 -070086 components: { IconChevron, PageSection, StatusIcon, Search },
Yoshie Muranaka386df452020-06-18 12:45:13 -070087 mixins: [TableDataFormatterMixin, TableSortMixin],
Yoshie Muranaka5918b482020-06-08 08:18:23 -070088 data() {
89 return {
90 fields: [
91 {
92 key: 'expandRow',
93 label: '',
94 tdClass: 'table-row-expand',
95 sortable: false
96 },
97 {
98 key: 'id',
99 label: this.$t('pageHardwareStatus.table.id'),
100 formatter: this.tableFormatter,
101 sortable: true
102 },
103 {
104 key: 'health',
105 label: this.$t('pageHardwareStatus.table.health'),
106 formatter: this.tableFormatter,
107 sortable: true
108 },
109 {
110 key: 'partNumber',
111 label: this.$t('pageHardwareStatus.table.partNumber'),
112 formatter: this.tableFormatter,
113 sortable: true
114 },
115 {
116 key: 'serialNumber',
117 label: this.$t('pageHardwareStatus.table.serialNumber'),
118 formatter: this.tableFormatter,
119 sortable: true
120 }
Yoshie Muranaka130b1b62020-06-18 14:29:57 -0700121 ],
122 searchFilter: null
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700123 };
124 },
125 computed: {
126 powerSupplies() {
127 return this.$store.getters['powerSupply/powerSupplies'];
128 }
129 },
130 created() {
131 this.$store.dispatch('powerSupply/getPowerSupply').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500132 // Emit initial data fetch complete to parent component
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700133 this.$root.$emit('hardwareStatus::powerSupplies::complete');
134 });
135 },
136 methods: {
137 sortCompare(a, b, key) {
138 if (key === 'health') {
139 return this.sortStatus(a, b, key);
140 }
Yoshie Muranaka130b1b62020-06-18 14:29:57 -0700141 },
142 onChangeSearchInput(searchValue) {
143 this.searchFilter = searchValue;
Yoshie Muranaka5918b482020-06-08 08:18:23 -0700144 }
145 }
146};
147</script>