blob: 97116ca2dfa20bfd2eb8a14d6333f60f1a08bc1f [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>
Sukanya Pandey99010962020-07-27 21:44:47 +05307 <b-col sm="6" md="3" xl="2">
8 <table-cell-count
9 :filtered-items-count="filteredRows"
10 :total-number-of-cells="dimms.length"
11 ></table-cell-count>
12 </b-col>
Yoshie Muranaka41770142020-06-18 14:00:55 -070013 </b-row>
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070014 <b-table
15 sort-icon-left
16 no-sort-reset
17 sort-by="health"
SurenNeware5e25e282020-07-08 15:57:23 +053018 responsive="md"
SurenNeware307382e2020-07-27 20:45:14 +053019 show-empty
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070020 :items="dimms"
21 :fields="fields"
22 :sort-desc="true"
23 :sort-compare="sortCompare"
Yoshie Muranaka41770142020-06-18 14:00:55 -070024 :filter="searchFilter"
SurenNeware307382e2020-07-27 20:45:14 +053025 :empty-text="$t('global.table.emptyMessage')"
SurenNeware156a0e62020-08-28 19:20:03 +053026 :empty-filtered-text="$t('global.table.emptySearchMessage')"
Sukanya Pandey99010962020-07-27 21:44:47 +053027 @filtered="onFiltered"
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070028 >
29 <!-- Expand chevron icon -->
30 <template v-slot:cell(expandRow)="row">
Dixsie Wolmers83133762020-07-15 08:45:19 -050031 <b-button
32 variant="link"
33 data-test-id="hardwareStatus-button-expandDimms"
34 @click="row.toggleDetails"
35 >
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070036 <icon-chevron />
37 </b-button>
38 </template>
39
40 <!-- Health -->
41 <template v-slot:cell(health)="{ value }">
42 <status-icon :status="statusIcon(value)" />
43 {{ value }}
44 </template>
45
46 <template v-slot:row-details="{ item }">
47 <b-container fluid>
48 <b-row>
49 <b-col sm="6" xl="4">
50 <dl>
51 <!-- Status state -->
52 <dt>{{ $t('pageHardwareStatus.table.statusState') }}:</dt>
53 <dd>{{ tableFormatter(item.statusState) }}</dd>
54 </dl>
55 </b-col>
56 </b-row>
57 </b-container>
58 </template>
59 </b-table>
60 </page-section>
61</template>
62
63<script>
64import PageSection from '@/components/Global/PageSection';
65import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
66
67import StatusIcon from '@/components/Global/StatusIcon';
Sukanya Pandey99010962020-07-27 21:44:47 +053068import TableCellCount from '@/components/Global/TableCellCount';
69
Yoshie Muranaka386df452020-06-18 12:45:13 -070070import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin';
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070071import TableSortMixin from '@/components/Mixins/TableSortMixin';
Yoshie Muranaka41770142020-06-18 14:00:55 -070072import Search from '@/components/Global/Search';
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070073
74export default {
Sukanya Pandey99010962020-07-27 21:44:47 +053075 components: { IconChevron, PageSection, StatusIcon, Search, TableCellCount },
Yoshie Muranaka386df452020-06-18 12:45:13 -070076 mixins: [TableDataFormatterMixin, TableSortMixin],
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070077 data() {
78 return {
79 fields: [
80 {
81 key: 'expandRow',
82 label: '',
83 tdClass: 'table-row-expand',
84 sortable: false
85 },
86 {
87 key: 'id',
88 label: this.$t('pageHardwareStatus.table.id'),
89 formatter: this.tableFormatter,
90 sortable: true
91 },
92 {
93 key: 'health',
94 label: this.$t('pageHardwareStatus.table.health'),
95 formatter: this.tableFormatter,
96 sortable: true
97 },
98 {
99 key: 'partNumber',
100 label: this.$t('pageHardwareStatus.table.partNumber'),
101 formatter: this.tableFormatter,
102 sortable: true
103 },
104 {
105 key: 'serialNumber',
106 label: this.$t('pageHardwareStatus.table.serialNumber'),
107 formatter: this.tableFormatter,
108 sortable: true
109 }
Yoshie Muranaka41770142020-06-18 14:00:55 -0700110 ],
Sukanya Pandey99010962020-07-27 21:44:47 +0530111 searchFilter: null,
112 searchTotalFilteredRows: 0
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700113 };
114 },
115 computed: {
Sukanya Pandey99010962020-07-27 21:44:47 +0530116 filteredRows() {
117 return this.searchFilter
118 ? this.searchTotalFilteredRows
119 : this.dimms.length;
120 },
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700121 dimms() {
122 return this.$store.getters['memory/dimms'];
123 }
124 },
125 created() {
126 this.$store.dispatch('memory/getDimms').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500127 // Emit initial data fetch complete to parent component
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700128 this.$root.$emit('hardwareStatus::dimmSlot::complete');
129 });
130 },
131 methods: {
132 sortCompare(a, b, key) {
133 if (key === 'health') {
134 return this.sortStatus(a, b, key);
135 }
Yoshie Muranaka41770142020-06-18 14:00:55 -0700136 },
137 onChangeSearchInput(searchValue) {
138 this.searchFilter = searchValue;
Sukanya Pandey99010962020-07-27 21:44:47 +0530139 },
140 onFiltered(filteredItems) {
141 this.searchTotalFilteredRows = filteredItems.length;
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700142 }
143 }
144};
145</script>