blob: 763ab267970ed4dfbaed7dcfda56237e0a1d4cdd [file] [log] [blame]
Yoshie Muranaka5918b482020-06-08 08:18:23 -07001<template>
2 <page-section :section-title="$t('pageHardwareStatus.powerSupplies')">
3 <b-table
4 sort-icon-left
5 no-sort-reset
6 sort-by="health"
7 :items="powerSupplies"
8 :fields="fields"
9 :sort-desc="true"
10 :sort-compare="sortCompare"
11 >
12 <!-- Expand chevron icon -->
13 <template v-slot:cell(expandRow)="row">
14 <b-button variant="link" @click="row.toggleDetails">
15 <icon-chevron />
16 </b-button>
17 </template>
18
19 <!-- Health -->
20 <template v-slot:cell(health)="{ value }">
21 <status-icon :status="statusIcon(value)" />
22 {{ value }}
23 </template>
24
25 <template v-slot:row-details="{ item }">
26 <b-container fluid>
27 <b-row>
28 <b-col sm="6" xl="4">
29 <dl>
30 <!-- Efficiency percent -->
31 <dt>{{ $t('pageHardwareStatus.table.efficiencyPercent') }}:</dt>
32 <dd>{{ tableFormatter(item.efficiencyPercent) }}</dd>
33 <br />
34 <!-- Firmware version -->
35 <dt>{{ $t('pageHardwareStatus.table.firmwareVersion') }}:</dt>
36 <dd>{{ tableFormatter(item.firmwareVersion) }}</dd>
37 <br />
38 <!-- Indicator LED -->
39 <dt>{{ $t('pageHardwareStatus.table.indicatorLed') }}:</dt>
40 <dd>{{ tableFormatter(item.indicatorLed) }}</dd>
41 </dl>
42 </b-col>
43 <b-col sm="6" xl="4">
44 <dl>
45 <!-- Model -->
46 <dt>{{ $t('pageHardwareStatus.table.model') }}:</dt>
47 <dd>{{ tableFormatter(item.model) }}</dd>
48 <br />
49 <!-- Power input watts -->
50 <dt>{{ $t('pageHardwareStatus.table.powerInputWatts') }}:</dt>
51 <dd>{{ tableFormatter(item.powerInputWatts) }}</dd>
52 <br />
53 <!-- Status state -->
54 <dt>{{ $t('pageHardwareStatus.table.statusState') }}:</dt>
55 <dd>{{ tableFormatter(item.statusState) }}</dd>
56 </dl>
57 </b-col>
58 </b-row>
59 </b-container>
60 </template>
61 </b-table>
62 </page-section>
63</template>
64
65<script>
66import PageSection from '@/components/Global/PageSection';
67import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
68
69import StatusIcon from '@/components/Global/StatusIcon';
Yoshie Muranaka386df452020-06-18 12:45:13 -070070import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin';
Yoshie Muranaka5918b482020-06-08 08:18:23 -070071import TableSortMixin from '@/components/Mixins/TableSortMixin';
72
73export default {
74 components: { IconChevron, PageSection, StatusIcon },
Yoshie Muranaka386df452020-06-18 12:45:13 -070075 mixins: [TableDataFormatterMixin, TableSortMixin],
Yoshie Muranaka5918b482020-06-08 08:18:23 -070076 data() {
77 return {
78 fields: [
79 {
80 key: 'expandRow',
81 label: '',
82 tdClass: 'table-row-expand',
83 sortable: false
84 },
85 {
86 key: 'id',
87 label: this.$t('pageHardwareStatus.table.id'),
88 formatter: this.tableFormatter,
89 sortable: true
90 },
91 {
92 key: 'health',
93 label: this.$t('pageHardwareStatus.table.health'),
94 formatter: this.tableFormatter,
95 sortable: true
96 },
97 {
98 key: 'partNumber',
99 label: this.$t('pageHardwareStatus.table.partNumber'),
100 formatter: this.tableFormatter,
101 sortable: true
102 },
103 {
104 key: 'serialNumber',
105 label: this.$t('pageHardwareStatus.table.serialNumber'),
106 formatter: this.tableFormatter,
107 sortable: true
108 }
109 ]
110 };
111 },
112 computed: {
113 powerSupplies() {
114 return this.$store.getters['powerSupply/powerSupplies'];
115 }
116 },
117 created() {
118 this.$store.dispatch('powerSupply/getPowerSupply').finally(() => {
119 // Emit intial data fetch complete to parent component
120 this.$root.$emit('hardwareStatus::powerSupplies::complete');
121 });
122 },
123 methods: {
124 sortCompare(a, b, key) {
125 if (key === 'health') {
126 return this.sortStatus(a, b, key);
127 }
128 }
129 }
130};
131</script>