blob: 9cacad0927a566a0f937796f11e5873e6a552a3c [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')"
Yoshie Muranakae24b17d2020-06-08 11:03:11 -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-expandDimms"
26 @click="row.toggleDetails"
27 >
Yoshie Muranakae24b17d2020-06-08 11:03:11 -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 Muranakae24b17d2020-06-08 11:03:11 -070061import TableSortMixin from '@/components/Mixins/TableSortMixin';
Yoshie Muranaka41770142020-06-18 14:00:55 -070062import Search from '@/components/Global/Search';
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070063
64export default {
Yoshie Muranaka41770142020-06-18 14:00:55 -070065 components: { IconChevron, PageSection, StatusIcon, Search },
Yoshie Muranaka386df452020-06-18 12:45:13 -070066 mixins: [TableDataFormatterMixin, TableSortMixin],
Yoshie Muranakae24b17d2020-06-08 11:03:11 -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 Muranaka41770142020-06-18 14:00:55 -0700100 ],
101 searchFilter: null
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700102 };
103 },
104 computed: {
105 dimms() {
106 return this.$store.getters['memory/dimms'];
107 }
108 },
109 created() {
110 this.$store.dispatch('memory/getDimms').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500111 // Emit initial data fetch complete to parent component
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700112 this.$root.$emit('hardwareStatus::dimmSlot::complete');
113 });
114 },
115 methods: {
116 sortCompare(a, b, key) {
117 if (key === 'health') {
118 return this.sortStatus(a, b, key);
119 }
Yoshie Muranaka41770142020-06-18 14:00:55 -0700120 },
121 onChangeSearchInput(searchValue) {
122 this.searchFilter = searchValue;
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700123 }
124 }
125};
126</script>