blob: 70d5d6d9960fa078535b60ad438d8ec550d5ca94 [file] [log] [blame]
Yoshie Muranakab89a53c2020-06-15 13:25:46 -07001<template>
2 <page-section :section-title="$t('pageHardwareStatus.fans')">
Yoshie Muranakac069c672020-06-18 14:21:50 -07003 <b-row>
4 <b-col sm="6" md="5" xl="4">
5 <search @changeSearch="onChangeSearchInput" />
6 </b-col>
7 </b-row>
Yoshie Muranakab89a53c2020-06-15 13:25:46 -07008 <b-table
9 sort-icon-left
10 no-sort-reset
11 sort-by="health"
12 :items="fans"
13 :fields="fields"
14 :sort-desc="true"
15 :sort-compare="sortCompare"
Yoshie Muranakac069c672020-06-18 14:21:50 -070016 :filter="searchFilter"
Yoshie Muranakab89a53c2020-06-15 13:25:46 -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-expandFans"
23 @click="row.toggleDetails"
24 >
Yoshie Muranakab89a53c2020-06-15 13:25:46 -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 <!-- Status state -->
41 <dt>{{ $t('pageHardwareStatus.table.statusState') }}:</dt>
42 <dd>{{ tableFormatter(item.statusState) }}</dd>
43 </dl>
44 </b-col>
45 </b-row>
46 </b-container>
47 </template>
48 </b-table>
49 </page-section>
50</template>
51
52<script>
53import PageSection from '@/components/Global/PageSection';
54import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
55
56import StatusIcon from '@/components/Global/StatusIcon';
Yoshie Muranaka386df452020-06-18 12:45:13 -070057import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin';
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070058import TableSortMixin from '@/components/Mixins/TableSortMixin';
Yoshie Muranakac069c672020-06-18 14:21:50 -070059import Search from '@/components/Global/Search';
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070060
61export default {
Yoshie Muranakac069c672020-06-18 14:21:50 -070062 components: { IconChevron, PageSection, StatusIcon, Search },
Yoshie Muranaka386df452020-06-18 12:45:13 -070063 mixins: [TableDataFormatterMixin, TableSortMixin],
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070064 data() {
65 return {
66 fields: [
67 {
68 key: 'expandRow',
69 label: '',
70 tdClass: 'table-row-expand',
71 sortable: false
72 },
73 {
74 key: 'id',
75 label: this.$t('pageHardwareStatus.table.id'),
76 formatter: this.tableFormatter,
77 sortable: true
78 },
79 {
80 key: 'health',
81 label: this.$t('pageHardwareStatus.table.health'),
82 formatter: this.tableFormatter,
83 sortable: true
84 },
85 {
86 key: 'partNumber',
87 label: this.$t('pageHardwareStatus.table.partNumber'),
88 formatter: this.tableFormatter,
89 sortable: true
90 },
91 {
92 key: 'serialNumber',
93 label: this.$t('pageHardwareStatus.table.serialNumber'),
94 formatter: this.tableFormatter,
95 sortable: true
96 }
Yoshie Muranakac069c672020-06-18 14:21:50 -070097 ],
98 searchFilter: null
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070099 };
100 },
101 computed: {
102 fans() {
103 return this.$store.getters['fan/fans'];
104 }
105 },
106 created() {
107 this.$store.dispatch('fan/getFanInfo').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500108 // Emit initial data fetch complete to parent component
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700109 this.$root.$emit('hardwareStatus::fans::complete');
110 });
111 },
112 methods: {
113 sortCompare(a, b, key) {
114 if (key === 'health') {
115 return this.sortStatus(a, b, key);
116 }
Yoshie Muranakac069c672020-06-18 14:21:50 -0700117 },
118 onChangeSearchInput(searchValue) {
119 this.searchFilter = searchValue;
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700120 }
121 }
122};
123</script>