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