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