blob: 5ba8b599559b6bab5bb7444e56c757fe3fe69142 [file] [log] [blame]
Yoshie Muranakae24b17d2020-06-08 11:03:11 -07001<template>
2 <page-section :section-title="$t('pageHardwareStatus.dimmSlot')">
3 <b-table
4 sort-icon-left
5 no-sort-reset
6 sort-by="health"
7 :items="dimms"
8 :fields="fields"
9 :sort-desc="true"
10 :sort-compare="sortCompare"
11 >
12 <!-- Expand chevron icon -->
13 <template v-slot:cell(expandRow)="row">
14 <b-button variant="link" @click="row.toggleDetails">
15 <icon-chevron />
16 </b-button>
17 </template>
18
19 <!-- Health -->
20 <template v-slot:cell(health)="{ value }">
21 <status-icon :status="statusIcon(value)" />
22 {{ value }}
23 </template>
24
25 <template v-slot:row-details="{ item }">
26 <b-container fluid>
27 <b-row>
28 <b-col sm="6" xl="4">
29 <dl>
30 <!-- Status state -->
31 <dt>{{ $t('pageHardwareStatus.table.statusState') }}:</dt>
32 <dd>{{ tableFormatter(item.statusState) }}</dd>
33 </dl>
34 </b-col>
35 </b-row>
36 </b-container>
37 </template>
38 </b-table>
39 </page-section>
40</template>
41
42<script>
43import PageSection from '@/components/Global/PageSection';
44import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
45
46import StatusIcon from '@/components/Global/StatusIcon';
Yoshie Muranaka386df452020-06-18 12:45:13 -070047import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin';
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070048import TableSortMixin from '@/components/Mixins/TableSortMixin';
49
50export default {
51 components: { IconChevron, PageSection, StatusIcon },
Yoshie Muranaka386df452020-06-18 12:45:13 -070052 mixins: [TableDataFormatterMixin, TableSortMixin],
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070053 data() {
54 return {
55 fields: [
56 {
57 key: 'expandRow',
58 label: '',
59 tdClass: 'table-row-expand',
60 sortable: false
61 },
62 {
63 key: 'id',
64 label: this.$t('pageHardwareStatus.table.id'),
65 formatter: this.tableFormatter,
66 sortable: true
67 },
68 {
69 key: 'health',
70 label: this.$t('pageHardwareStatus.table.health'),
71 formatter: this.tableFormatter,
72 sortable: true
73 },
74 {
75 key: 'partNumber',
76 label: this.$t('pageHardwareStatus.table.partNumber'),
77 formatter: this.tableFormatter,
78 sortable: true
79 },
80 {
81 key: 'serialNumber',
82 label: this.$t('pageHardwareStatus.table.serialNumber'),
83 formatter: this.tableFormatter,
84 sortable: true
85 }
86 ]
87 };
88 },
89 computed: {
90 dimms() {
91 return this.$store.getters['memory/dimms'];
92 }
93 },
94 created() {
95 this.$store.dispatch('memory/getDimms').finally(() => {
96 // Emit intial data fetch complete to parent component
97 this.$root.$emit('hardwareStatus::dimmSlot::complete');
98 });
99 },
100 methods: {
101 sortCompare(a, b, key) {
102 if (key === 'health') {
103 return this.sortStatus(a, b, key);
104 }
105 }
106 }
107};
108</script>