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