blob: ed370b536e83dd7b3cdc45ce339ff2ba959774fe [file] [log] [blame]
Yoshie Muranakae24b17d2020-06-08 11:03:11 -07001<template>
Sandeepa Singh7affc522021-07-06 16:29:10 +05302 <page-section :section-title="$t('pageInventory.dimmSlot')">
SurenNeware787635a2020-11-24 22:42:42 +05303 <b-row class="align-items-end">
Yoshie Muranaka41770142020-06-18 14:00:55 -07004 <b-col sm="6" md="5" xl="4">
Dixsie Wolmers9b22b492020-09-07 21:26:06 -05005 <search
Sukanya Pandeyedb8a772020-10-29 11:33:42 +05306 @change-search="onChangeSearchInput"
7 @clear-search="onClearSearchInput"
Dixsie Wolmers9b22b492020-09-07 21:26:06 -05008 />
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 -->
Derick Montague602e98a2020-10-21 16:20:00 -050034 <template #cell(expandRow)="row">
Dixsie Wolmers83133762020-07-15 08:45:19 -050035 <b-button
36 variant="link"
37 data-test-id="hardwareStatus-button-expandDimms"
Dixsie Wolmers30f11f82020-11-10 16:07:56 -060038 :title="expandRowLabel"
39 class="btn-icon-only"
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050040 @click="toggleRowDetails(row)"
Dixsie Wolmers83133762020-07-15 08:45:19 -050041 >
Dixsie Wolmers30f11f82020-11-10 16:07:56 -060042 <icon-chevron />
SurenNeware6e2cb972020-12-24 20:58:16 +053043 <span class="sr-only">{{ expandRowLabel }}</span>
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070044 </b-button>
45 </template>
46
47 <!-- Health -->
Derick Montague602e98a2020-10-21 16:20:00 -050048 <template #cell(health)="{ value }">
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070049 <status-icon :status="statusIcon(value)" />
50 {{ value }}
51 </template>
52
Derick Montague602e98a2020-10-21 16:20:00 -050053 <template #row-details="{ item }">
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070054 <b-container fluid>
55 <b-row>
56 <b-col sm="6" xl="4">
57 <dl>
58 <!-- Status state -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053059 <dt>{{ $t('pageInventory.table.statusState') }}:</dt>
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070060 <dd>{{ tableFormatter(item.statusState) }}</dd>
61 </dl>
62 </b-col>
63 </b-row>
64 </b-container>
65 </template>
66 </b-table>
67 </page-section>
68</template>
69
70<script>
71import PageSection from '@/components/Global/PageSection';
72import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
73
74import StatusIcon from '@/components/Global/StatusIcon';
Sukanya Pandey99010962020-07-27 21:44:47 +053075import TableCellCount from '@/components/Global/TableCellCount';
76
Yoshie Muranaka386df452020-06-18 12:45:13 -070077import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin';
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070078import TableSortMixin from '@/components/Mixins/TableSortMixin';
Yoshie Muranaka41770142020-06-18 14:00:55 -070079import Search from '@/components/Global/Search';
SurenNewareba91c492020-10-27 14:18:54 +053080import SearchFilterMixin, {
81 searchFilter,
82} from '@/components/Mixins/SearchFilterMixin';
83import TableRowExpandMixin, {
84 expandRowLabel,
85} from '@/components/Mixins/TableRowExpandMixin';
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070086
87export default {
Sukanya Pandey99010962020-07-27 21:44:47 +053088 components: { IconChevron, PageSection, StatusIcon, Search, TableCellCount },
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050089 mixins: [
90 TableRowExpandMixin,
91 TableDataFormatterMixin,
92 TableSortMixin,
Derick Montague602e98a2020-10-21 16:20:00 -050093 SearchFilterMixin,
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050094 ],
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070095 data() {
96 return {
97 fields: [
98 {
99 key: 'expandRow',
100 label: '',
101 tdClass: 'table-row-expand',
Derick Montague602e98a2020-10-21 16:20:00 -0500102 sortable: false,
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700103 },
104 {
105 key: 'id',
Sandeepa Singh7affc522021-07-06 16:29:10 +0530106 label: this.$t('pageInventory.table.id'),
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700107 formatter: this.tableFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500108 sortable: true,
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700109 },
110 {
111 key: 'health',
Sandeepa Singh7affc522021-07-06 16:29:10 +0530112 label: this.$t('pageInventory.table.health'),
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700113 formatter: this.tableFormatter,
Dixsie Wolmersa04d46f2020-10-22 06:34:56 -0500114 sortable: true,
Derick Montague602e98a2020-10-21 16:20:00 -0500115 tdClass: 'text-nowrap',
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700116 },
117 {
118 key: 'partNumber',
Sandeepa Singh7affc522021-07-06 16:29:10 +0530119 label: this.$t('pageInventory.table.partNumber'),
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700120 formatter: this.tableFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500121 sortable: true,
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700122 },
123 {
124 key: 'serialNumber',
Sandeepa Singh7affc522021-07-06 16:29:10 +0530125 label: this.$t('pageInventory.table.serialNumber'),
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700126 formatter: this.tableFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500127 sortable: true,
128 },
Yoshie Muranaka41770142020-06-18 14:00:55 -0700129 ],
SurenNewareba91c492020-10-27 14:18:54 +0530130 searchFilter: searchFilter,
Derick Montague602e98a2020-10-21 16:20:00 -0500131 searchTotalFilteredRows: 0,
SurenNewareba91c492020-10-27 14:18:54 +0530132 expandRowLabel: expandRowLabel,
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700133 };
134 },
135 computed: {
Sukanya Pandey99010962020-07-27 21:44:47 +0530136 filteredRows() {
137 return this.searchFilter
138 ? this.searchTotalFilteredRows
139 : this.dimms.length;
140 },
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700141 dimms() {
142 return this.$store.getters['memory/dimms'];
Derick Montague602e98a2020-10-21 16:20:00 -0500143 },
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700144 },
145 created() {
146 this.$store.dispatch('memory/getDimms').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500147 // Emit initial data fetch complete to parent component
Sukanya Pandeyedb8a772020-10-29 11:33:42 +0530148 this.$root.$emit('hardware-status-dimm-slot-complete');
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700149 });
150 },
151 methods: {
152 sortCompare(a, b, key) {
153 if (key === 'health') {
154 return this.sortStatus(a, b, key);
155 }
Yoshie Muranaka41770142020-06-18 14:00:55 -0700156 },
Sukanya Pandey99010962020-07-27 21:44:47 +0530157 onFiltered(filteredItems) {
158 this.searchTotalFilteredRows = filteredItems.length;
Derick Montague602e98a2020-10-21 16:20:00 -0500159 },
160 },
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700161};
162</script>