blob: babb8d0733b1a755930e424d9a508180ddbb177a [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
Sukanya Pandeyfde429e2020-09-14 20:48:39 +053020 hover
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070021 sort-by="health"
SurenNeware5e25e282020-07-08 15:57:23 +053022 responsive="md"
SurenNeware307382e2020-07-27 20:45:14 +053023 show-empty
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070024 :items="dimms"
25 :fields="fields"
26 :sort-desc="true"
27 :sort-compare="sortCompare"
Yoshie Muranaka41770142020-06-18 14:00:55 -070028 :filter="searchFilter"
SurenNeware307382e2020-07-27 20:45:14 +053029 :empty-text="$t('global.table.emptyMessage')"
SurenNeware156a0e62020-08-28 19:20:03 +053030 :empty-filtered-text="$t('global.table.emptySearchMessage')"
Sukanya Pandey99010962020-07-27 21:44:47 +053031 @filtered="onFiltered"
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070032 >
33 <!-- Expand chevron icon -->
34 <template v-slot:cell(expandRow)="row">
Dixsie Wolmers83133762020-07-15 08:45:19 -050035 <b-button
36 variant="link"
37 data-test-id="hardwareStatus-button-expandDimms"
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050038 :aria-label="expandRowLabel"
39 @click="toggleRowDetails(row)"
Dixsie Wolmers83133762020-07-15 08:45:19 -050040 >
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050041 <icon-chevron :title="expandRowLabel" />
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070042 </b-button>
43 </template>
44
45 <!-- Health -->
46 <template v-slot:cell(health)="{ value }">
47 <status-icon :status="statusIcon(value)" />
48 {{ value }}
49 </template>
50
51 <template v-slot:row-details="{ item }">
52 <b-container fluid>
53 <b-row>
54 <b-col sm="6" xl="4">
55 <dl>
56 <!-- Status state -->
57 <dt>{{ $t('pageHardwareStatus.table.statusState') }}:</dt>
58 <dd>{{ tableFormatter(item.statusState) }}</dd>
59 </dl>
60 </b-col>
61 </b-row>
62 </b-container>
63 </template>
64 </b-table>
65 </page-section>
66</template>
67
68<script>
69import PageSection from '@/components/Global/PageSection';
70import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
71
72import StatusIcon from '@/components/Global/StatusIcon';
Sukanya Pandey99010962020-07-27 21:44:47 +053073import TableCellCount from '@/components/Global/TableCellCount';
74
Yoshie Muranaka386df452020-06-18 12:45:13 -070075import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin';
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070076import TableSortMixin from '@/components/Mixins/TableSortMixin';
Yoshie Muranaka41770142020-06-18 14:00:55 -070077import Search from '@/components/Global/Search';
Dixsie Wolmers9b22b492020-09-07 21:26:06 -050078import SearchFilterMixin from '@/components/Mixins/SearchFilterMixin';
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050079import TableRowExpandMixin from '@/components/Mixins/TableRowExpandMixin';
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070080
81export default {
Sukanya Pandey99010962020-07-27 21:44:47 +053082 components: { IconChevron, PageSection, StatusIcon, Search, TableCellCount },
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050083 mixins: [
84 TableRowExpandMixin,
85 TableDataFormatterMixin,
86 TableSortMixin,
87 SearchFilterMixin
88 ],
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070089 data() {
90 return {
91 fields: [
92 {
93 key: 'expandRow',
94 label: '',
95 tdClass: 'table-row-expand',
96 sortable: false
97 },
98 {
99 key: 'id',
100 label: this.$t('pageHardwareStatus.table.id'),
101 formatter: this.tableFormatter,
102 sortable: true
103 },
104 {
105 key: 'health',
106 label: this.$t('pageHardwareStatus.table.health'),
107 formatter: this.tableFormatter,
Dixsie Wolmersa04d46f2020-10-22 06:34:56 -0500108 sortable: true,
109 tdClass: 'text-nowrap'
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700110 },
111 {
112 key: 'partNumber',
113 label: this.$t('pageHardwareStatus.table.partNumber'),
114 formatter: this.tableFormatter,
115 sortable: true
116 },
117 {
118 key: 'serialNumber',
119 label: this.$t('pageHardwareStatus.table.serialNumber'),
120 formatter: this.tableFormatter,
121 sortable: true
122 }
Yoshie Muranaka41770142020-06-18 14:00:55 -0700123 ],
Sukanya Pandey99010962020-07-27 21:44:47 +0530124 searchTotalFilteredRows: 0
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700125 };
126 },
127 computed: {
Sukanya Pandey99010962020-07-27 21:44:47 +0530128 filteredRows() {
129 return this.searchFilter
130 ? this.searchTotalFilteredRows
131 : this.dimms.length;
132 },
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700133 dimms() {
134 return this.$store.getters['memory/dimms'];
135 }
136 },
137 created() {
138 this.$store.dispatch('memory/getDimms').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500139 // Emit initial data fetch complete to parent component
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700140 this.$root.$emit('hardwareStatus::dimmSlot::complete');
141 });
142 },
143 methods: {
144 sortCompare(a, b, key) {
145 if (key === 'health') {
146 return this.sortStatus(a, b, key);
147 }
Yoshie Muranaka41770142020-06-18 14:00:55 -0700148 },
Sukanya Pandey99010962020-07-27 21:44:47 +0530149 onFiltered(filteredItems) {
150 this.searchTotalFilteredRows = filteredItems.length;
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700151 }
152 }
153};
154</script>