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