blob: aa5fc89ffd2441aa1cf5ac5b00d8896aea41baf1 [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">
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 <!-- Status state -->
37 <dt>{{ $t('pageHardwareStatus.table.statusState') }}:</dt>
38 <dd>{{ tableFormatter(item.statusState) }}</dd>
39 </dl>
40 </b-col>
41 </b-row>
42 </b-container>
43 </template>
44 </b-table>
45 </page-section>
46</template>
47
48<script>
49import PageSection from '@/components/Global/PageSection';
50import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
51
52import StatusIcon from '@/components/Global/StatusIcon';
Yoshie Muranaka386df452020-06-18 12:45:13 -070053import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin';
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070054import TableSortMixin from '@/components/Mixins/TableSortMixin';
Yoshie Muranakac069c672020-06-18 14:21:50 -070055import Search from '@/components/Global/Search';
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070056
57export default {
Yoshie Muranakac069c672020-06-18 14:21:50 -070058 components: { IconChevron, PageSection, StatusIcon, Search },
Yoshie Muranaka386df452020-06-18 12:45:13 -070059 mixins: [TableDataFormatterMixin, TableSortMixin],
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070060 data() {
61 return {
62 fields: [
63 {
64 key: 'expandRow',
65 label: '',
66 tdClass: 'table-row-expand',
67 sortable: false
68 },
69 {
70 key: 'id',
71 label: this.$t('pageHardwareStatus.table.id'),
72 formatter: this.tableFormatter,
73 sortable: true
74 },
75 {
76 key: 'health',
77 label: this.$t('pageHardwareStatus.table.health'),
78 formatter: this.tableFormatter,
79 sortable: true
80 },
81 {
82 key: 'partNumber',
83 label: this.$t('pageHardwareStatus.table.partNumber'),
84 formatter: this.tableFormatter,
85 sortable: true
86 },
87 {
88 key: 'serialNumber',
89 label: this.$t('pageHardwareStatus.table.serialNumber'),
90 formatter: this.tableFormatter,
91 sortable: true
92 }
Yoshie Muranakac069c672020-06-18 14:21:50 -070093 ],
94 searchFilter: null
Yoshie Muranakab89a53c2020-06-15 13:25:46 -070095 };
96 },
97 computed: {
98 fans() {
99 return this.$store.getters['fan/fans'];
100 }
101 },
102 created() {
103 this.$store.dispatch('fan/getFanInfo').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500104 // Emit initial data fetch complete to parent component
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700105 this.$root.$emit('hardwareStatus::fans::complete');
106 });
107 },
108 methods: {
109 sortCompare(a, b, key) {
110 if (key === 'health') {
111 return this.sortStatus(a, b, key);
112 }
Yoshie Muranakac069c672020-06-18 14:21:50 -0700113 },
114 onChangeSearchInput(searchValue) {
115 this.searchFilter = searchValue;
Yoshie Muranakab89a53c2020-06-15 13:25:46 -0700116 }
117 }
118};
119</script>