blob: b72a6cc29e51caaecd7938bf5e09f432e8f54f83 [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">
Dixsie Wolmers9b22b492020-09-07 21:26:06 -05005 <search
6 @changeSearch="onChangeSearchInput"
7 @clearSearch="onClearSearchInput"
8 />
Yoshie Muranaka41770142020-06-18 14:00:55 -07009 </b-col>
Sukanya Pandey99010962020-07-27 21:44:47 +053010 <b-col sm="6" md="3" xl="2">
11 <table-cell-count
12 :filtered-items-count="filteredRows"
13 :total-number-of-cells="dimms.length"
14 ></table-cell-count>
15 </b-col>
Yoshie Muranaka41770142020-06-18 14:00:55 -070016 </b-row>
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070017 <b-table
18 sort-icon-left
19 no-sort-reset
20 sort-by="health"
SurenNeware5e25e282020-07-08 15:57:23 +053021 responsive="md"
SurenNeware307382e2020-07-27 20:45:14 +053022 show-empty
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070023 :items="dimms"
24 :fields="fields"
25 :sort-desc="true"
26 :sort-compare="sortCompare"
Yoshie Muranaka41770142020-06-18 14:00:55 -070027 :filter="searchFilter"
SurenNeware307382e2020-07-27 20:45:14 +053028 :empty-text="$t('global.table.emptyMessage')"
SurenNeware156a0e62020-08-28 19:20:03 +053029 :empty-filtered-text="$t('global.table.emptySearchMessage')"
Sukanya Pandey99010962020-07-27 21:44:47 +053030 @filtered="onFiltered"
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070031 >
32 <!-- Expand chevron icon -->
33 <template v-slot:cell(expandRow)="row">
Dixsie Wolmers83133762020-07-15 08:45:19 -050034 <b-button
35 variant="link"
36 data-test-id="hardwareStatus-button-expandDimms"
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050037 :aria-label="expandRowLabel"
38 @click="toggleRowDetails(row)"
Dixsie Wolmers83133762020-07-15 08:45:19 -050039 >
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050040 <icon-chevron :title="expandRowLabel" />
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070041 </b-button>
42 </template>
43
44 <!-- Health -->
45 <template v-slot:cell(health)="{ value }">
46 <status-icon :status="statusIcon(value)" />
47 {{ value }}
48 </template>
49
50 <template v-slot:row-details="{ item }">
51 <b-container fluid>
52 <b-row>
53 <b-col sm="6" xl="4">
54 <dl>
55 <!-- Status state -->
56 <dt>{{ $t('pageHardwareStatus.table.statusState') }}:</dt>
57 <dd>{{ tableFormatter(item.statusState) }}</dd>
58 </dl>
59 </b-col>
60 </b-row>
61 </b-container>
62 </template>
63 </b-table>
64 </page-section>
65</template>
66
67<script>
68import PageSection from '@/components/Global/PageSection';
69import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
70
71import StatusIcon from '@/components/Global/StatusIcon';
Sukanya Pandey99010962020-07-27 21:44:47 +053072import TableCellCount from '@/components/Global/TableCellCount';
73
Yoshie Muranaka386df452020-06-18 12:45:13 -070074import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin';
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070075import TableSortMixin from '@/components/Mixins/TableSortMixin';
Yoshie Muranaka41770142020-06-18 14:00:55 -070076import Search from '@/components/Global/Search';
Dixsie Wolmers9b22b492020-09-07 21:26:06 -050077import SearchFilterMixin from '@/components/Mixins/SearchFilterMixin';
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050078import TableRowExpandMixin from '@/components/Mixins/TableRowExpandMixin';
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070079
80export default {
Sukanya Pandey99010962020-07-27 21:44:47 +053081 components: { IconChevron, PageSection, StatusIcon, Search, TableCellCount },
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050082 mixins: [
83 TableRowExpandMixin,
84 TableDataFormatterMixin,
85 TableSortMixin,
86 SearchFilterMixin
87 ],
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070088 data() {
89 return {
90 fields: [
91 {
92 key: 'expandRow',
93 label: '',
94 tdClass: 'table-row-expand',
95 sortable: false
96 },
97 {
98 key: 'id',
99 label: this.$t('pageHardwareStatus.table.id'),
100 formatter: this.tableFormatter,
101 sortable: true
102 },
103 {
104 key: 'health',
105 label: this.$t('pageHardwareStatus.table.health'),
106 formatter: this.tableFormatter,
107 sortable: true
108 },
109 {
110 key: 'partNumber',
111 label: this.$t('pageHardwareStatus.table.partNumber'),
112 formatter: this.tableFormatter,
113 sortable: true
114 },
115 {
116 key: 'serialNumber',
117 label: this.$t('pageHardwareStatus.table.serialNumber'),
118 formatter: this.tableFormatter,
119 sortable: true
120 }
Yoshie Muranaka41770142020-06-18 14:00:55 -0700121 ],
Sukanya Pandey99010962020-07-27 21:44:47 +0530122 searchTotalFilteredRows: 0
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700123 };
124 },
125 computed: {
Sukanya Pandey99010962020-07-27 21:44:47 +0530126 filteredRows() {
127 return this.searchFilter
128 ? this.searchTotalFilteredRows
129 : this.dimms.length;
130 },
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700131 dimms() {
132 return this.$store.getters['memory/dimms'];
133 }
134 },
135 created() {
136 this.$store.dispatch('memory/getDimms').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500137 // Emit initial data fetch complete to parent component
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700138 this.$root.$emit('hardwareStatus::dimmSlot::complete');
139 });
140 },
141 methods: {
142 sortCompare(a, b, key) {
143 if (key === 'health') {
144 return this.sortStatus(a, b, key);
145 }
Yoshie Muranaka41770142020-06-18 14:00:55 -0700146 },
Sukanya Pandey99010962020-07-27 21:44:47 +0530147 onFiltered(filteredItems) {
148 this.searchTotalFilteredRows = filteredItems.length;
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700149 }
150 }
151};
152</script>