blob: ec7c16371803e86b13da4e6bf2452f78bc8b80ea [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"
37 @click="row.toggleDetails"
38 >
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070039 <icon-chevron />
40 </b-button>
41 </template>
42
43 <!-- Health -->
44 <template v-slot:cell(health)="{ value }">
45 <status-icon :status="statusIcon(value)" />
46 {{ value }}
47 </template>
48
49 <template v-slot:row-details="{ item }">
50 <b-container fluid>
51 <b-row>
52 <b-col sm="6" xl="4">
53 <dl>
54 <!-- Status state -->
55 <dt>{{ $t('pageHardwareStatus.table.statusState') }}:</dt>
56 <dd>{{ tableFormatter(item.statusState) }}</dd>
57 </dl>
58 </b-col>
59 </b-row>
60 </b-container>
61 </template>
62 </b-table>
63 </page-section>
64</template>
65
66<script>
67import PageSection from '@/components/Global/PageSection';
68import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
69
70import StatusIcon from '@/components/Global/StatusIcon';
Sukanya Pandey99010962020-07-27 21:44:47 +053071import TableCellCount from '@/components/Global/TableCellCount';
72
Yoshie Muranaka386df452020-06-18 12:45:13 -070073import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin';
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070074import TableSortMixin from '@/components/Mixins/TableSortMixin';
Yoshie Muranaka41770142020-06-18 14:00:55 -070075import Search from '@/components/Global/Search';
Dixsie Wolmers9b22b492020-09-07 21:26:06 -050076import SearchFilterMixin from '@/components/Mixins/SearchFilterMixin';
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070077
78export default {
Sukanya Pandey99010962020-07-27 21:44:47 +053079 components: { IconChevron, PageSection, StatusIcon, Search, TableCellCount },
Dixsie Wolmers9b22b492020-09-07 21:26:06 -050080 mixins: [TableDataFormatterMixin, TableSortMixin, SearchFilterMixin],
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070081 data() {
82 return {
83 fields: [
84 {
85 key: 'expandRow',
86 label: '',
87 tdClass: 'table-row-expand',
88 sortable: false
89 },
90 {
91 key: 'id',
92 label: this.$t('pageHardwareStatus.table.id'),
93 formatter: this.tableFormatter,
94 sortable: true
95 },
96 {
97 key: 'health',
98 label: this.$t('pageHardwareStatus.table.health'),
99 formatter: this.tableFormatter,
100 sortable: true
101 },
102 {
103 key: 'partNumber',
104 label: this.$t('pageHardwareStatus.table.partNumber'),
105 formatter: this.tableFormatter,
106 sortable: true
107 },
108 {
109 key: 'serialNumber',
110 label: this.$t('pageHardwareStatus.table.serialNumber'),
111 formatter: this.tableFormatter,
112 sortable: true
113 }
Yoshie Muranaka41770142020-06-18 14:00:55 -0700114 ],
Sukanya Pandey99010962020-07-27 21:44:47 +0530115 searchTotalFilteredRows: 0
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700116 };
117 },
118 computed: {
Sukanya Pandey99010962020-07-27 21:44:47 +0530119 filteredRows() {
120 return this.searchFilter
121 ? this.searchTotalFilteredRows
122 : this.dimms.length;
123 },
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700124 dimms() {
125 return this.$store.getters['memory/dimms'];
126 }
127 },
128 created() {
129 this.$store.dispatch('memory/getDimms').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500130 // Emit initial data fetch complete to parent component
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700131 this.$root.$emit('hardwareStatus::dimmSlot::complete');
132 });
133 },
134 methods: {
135 sortCompare(a, b, key) {
136 if (key === 'health') {
137 return this.sortStatus(a, b, key);
138 }
Yoshie Muranaka41770142020-06-18 14:00:55 -0700139 },
Sukanya Pandey99010962020-07-27 21:44:47 +0530140 onFiltered(filteredItems) {
141 this.searchTotalFilteredRows = filteredItems.length;
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700142 }
143 }
144};
145</script>