blob: 4fd077ba68116f8aab41c42a14c44fd2dcad1891 [file] [log] [blame]
Yoshie Muranakae24b17d2020-06-08 11:03:11 -07001<template>
2 <page-section :section-title="$t('pageHardwareStatus.dimmSlot')">
Yoshie Muranaka41770142020-06-18 14:00:55 -07003 <b-row>
4 <b-col sm="6" md="5" xl="4">
5 <search @changeSearch="onChangeSearchInput" />
6 </b-col>
7 </b-row>
Yoshie Muranakae24b17d2020-06-08 11:03:11 -07008 <b-table
9 sort-icon-left
10 no-sort-reset
11 sort-by="health"
SurenNeware5e25e282020-07-08 15:57:23 +053012 responsive="md"
SurenNeware307382e2020-07-27 20:45:14 +053013 show-empty
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070014 :items="dimms"
15 :fields="fields"
16 :sort-desc="true"
17 :sort-compare="sortCompare"
Yoshie Muranaka41770142020-06-18 14:00:55 -070018 :filter="searchFilter"
SurenNeware307382e2020-07-27 20:45:14 +053019 :empty-text="$t('global.table.emptyMessage')"
SurenNeware156a0e62020-08-28 19:20:03 +053020 :empty-filtered-text="$t('global.table.emptySearchMessage')"
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070021 >
22 <!-- Expand chevron icon -->
23 <template v-slot:cell(expandRow)="row">
Dixsie Wolmers83133762020-07-15 08:45:19 -050024 <b-button
25 variant="link"
26 data-test-id="hardwareStatus-button-expandDimms"
27 @click="row.toggleDetails"
28 >
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070029 <icon-chevron />
30 </b-button>
31 </template>
32
33 <!-- Health -->
34 <template v-slot:cell(health)="{ value }">
35 <status-icon :status="statusIcon(value)" />
36 {{ value }}
37 </template>
38
39 <template v-slot:row-details="{ item }">
40 <b-container fluid>
41 <b-row>
42 <b-col sm="6" xl="4">
43 <dl>
44 <!-- Status state -->
45 <dt>{{ $t('pageHardwareStatus.table.statusState') }}:</dt>
46 <dd>{{ tableFormatter(item.statusState) }}</dd>
47 </dl>
48 </b-col>
49 </b-row>
50 </b-container>
51 </template>
52 </b-table>
53 </page-section>
54</template>
55
56<script>
57import PageSection from '@/components/Global/PageSection';
58import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
59
60import StatusIcon from '@/components/Global/StatusIcon';
Yoshie Muranaka386df452020-06-18 12:45:13 -070061import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin';
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070062import TableSortMixin from '@/components/Mixins/TableSortMixin';
Yoshie Muranaka41770142020-06-18 14:00:55 -070063import Search from '@/components/Global/Search';
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070064
65export default {
Yoshie Muranaka41770142020-06-18 14:00:55 -070066 components: { IconChevron, PageSection, StatusIcon, Search },
Yoshie Muranaka386df452020-06-18 12:45:13 -070067 mixins: [TableDataFormatterMixin, TableSortMixin],
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070068 data() {
69 return {
70 fields: [
71 {
72 key: 'expandRow',
73 label: '',
74 tdClass: 'table-row-expand',
75 sortable: false
76 },
77 {
78 key: 'id',
79 label: this.$t('pageHardwareStatus.table.id'),
80 formatter: this.tableFormatter,
81 sortable: true
82 },
83 {
84 key: 'health',
85 label: this.$t('pageHardwareStatus.table.health'),
86 formatter: this.tableFormatter,
87 sortable: true
88 },
89 {
90 key: 'partNumber',
91 label: this.$t('pageHardwareStatus.table.partNumber'),
92 formatter: this.tableFormatter,
93 sortable: true
94 },
95 {
96 key: 'serialNumber',
97 label: this.$t('pageHardwareStatus.table.serialNumber'),
98 formatter: this.tableFormatter,
99 sortable: true
100 }
Yoshie Muranaka41770142020-06-18 14:00:55 -0700101 ],
102 searchFilter: null
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700103 };
104 },
105 computed: {
106 dimms() {
107 return this.$store.getters['memory/dimms'];
108 }
109 },
110 created() {
111 this.$store.dispatch('memory/getDimms').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500112 // Emit initial data fetch complete to parent component
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700113 this.$root.$emit('hardwareStatus::dimmSlot::complete');
114 });
115 },
116 methods: {
117 sortCompare(a, b, key) {
118 if (key === 'health') {
119 return this.sortStatus(a, b, key);
120 }
Yoshie Muranaka41770142020-06-18 14:00:55 -0700121 },
122 onChangeSearchInput(searchValue) {
123 this.searchFilter = searchValue;
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700124 }
125 }
126};
127</script>