blob: e9cbf049e16ae32e16960c56cc5e10f5ea7be33f [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
SurenNeware5e25e282020-07-08 15:57:23 +053011 responsive="md"
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070012 sort-by="health"
13 :items="fans"
14 :fields="fields"
15 :sort-desc="true"
16 :sort-compare="sortCompare"
Yoshie Muranakac069c672020-06-18 14:21:50 -070017 :filter="searchFilter"
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070018 >
19 <!-- Expand chevron icon -->
20 <template v-slot:cell(expandRow)="row">
Dixsie Wolmers83133762020-07-15 08:45:19 -050021 <b-button
22 variant="link"
23 data-test-id="hardwareStatus-button-expandFans"
24 @click="row.toggleDetails"
25 >
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070026 <icon-chevron />
27 </b-button>
28 </template>
29
30 <!-- Health -->
31 <template v-slot:cell(health)="{ value }">
32 <status-icon :status="statusIcon(value)" />
33 {{ value }}
34 </template>
35
36 <template v-slot:row-details="{ item }">
37 <b-container fluid>
38 <b-row>
39 <b-col sm="6" xl="4">
40 <dl>
41 <!-- Status state -->
42 <dt>{{ $t('pageHardwareStatus.table.statusState') }}:</dt>
43 <dd>{{ tableFormatter(item.statusState) }}</dd>
44 </dl>
45 </b-col>
46 </b-row>
47 </b-container>
48 </template>
49 </b-table>
50 </page-section>
51</template>
52
53<script>
54import PageSection from '@/components/Global/PageSection';
55import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
56
57import StatusIcon from '@/components/Global/StatusIcon';
Yoshie Muranaka386df452020-06-18 12:45:13 -070058import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin';
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070059import TableSortMixin from '@/components/Mixins/TableSortMixin';
Yoshie Muranakac069c672020-06-18 14:21:50 -070060import Search from '@/components/Global/Search';
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070061
62export default {
Yoshie Muranakac069c672020-06-18 14:21:50 -070063 components: { IconChevron, PageSection, StatusIcon, Search },
Yoshie Muranaka386df452020-06-18 12:45:13 -070064 mixins: [TableDataFormatterMixin, TableSortMixin],
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070065 data() {
66 return {
67 fields: [
68 {
69 key: 'expandRow',
70 label: '',
71 tdClass: 'table-row-expand',
72 sortable: false
73 },
74 {
75 key: 'id',
76 label: this.$t('pageHardwareStatus.table.id'),
77 formatter: this.tableFormatter,
78 sortable: true
79 },
80 {
81 key: 'health',
82 label: this.$t('pageHardwareStatus.table.health'),
83 formatter: this.tableFormatter,
84 sortable: true
85 },
86 {
87 key: 'partNumber',
88 label: this.$t('pageHardwareStatus.table.partNumber'),
89 formatter: this.tableFormatter,
90 sortable: true
91 },
92 {
93 key: 'serialNumber',
94 label: this.$t('pageHardwareStatus.table.serialNumber'),
95 formatter: this.tableFormatter,
96 sortable: true
97 }
Yoshie Muranakac069c672020-06-18 14:21:50 -070098 ],
99 searchFilter: null
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700100 };
101 },
102 computed: {
103 fans() {
104 return this.$store.getters['fan/fans'];
105 }
106 },
107 created() {
108 this.$store.dispatch('fan/getFanInfo').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500109 // Emit initial data fetch complete to parent component
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700110 this.$root.$emit('hardwareStatus::fans::complete');
111 });
112 },
113 methods: {
114 sortCompare(a, b, key) {
115 if (key === 'health') {
116 return this.sortStatus(a, b, key);
117 }
Yoshie Muranakac069c672020-06-18 14:21:50 -0700118 },
119 onChangeSearchInput(searchValue) {
120 this.searchFilter = searchValue;
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700121 }
122 }
123};
124</script>