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