blob: f4a850b0aca5773008215b91912f8b1e1a24d24b [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')"
Kenneth Fullbright41057852021-12-27 16:19:37 -060031 :busy="isBusy"
Sukanya Pandey99010962020-07-27 21:44:47 +053032 @filtered="onFiltered"
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070033 >
34 <!-- Expand chevron icon -->
Derick Montague602e98a2020-10-21 16:20:00 -050035 <template #cell(expandRow)="row">
Dixsie Wolmers83133762020-07-15 08:45:19 -050036 <b-button
37 variant="link"
38 data-test-id="hardwareStatus-button-expandDimms"
Dixsie Wolmers30f11f82020-11-10 16:07:56 -060039 :title="expandRowLabel"
40 class="btn-icon-only"
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050041 @click="toggleRowDetails(row)"
Dixsie Wolmers83133762020-07-15 08:45:19 -050042 >
Dixsie Wolmers30f11f82020-11-10 16:07:56 -060043 <icon-chevron />
SurenNeware6e2cb972020-12-24 20:58:16 +053044 <span class="sr-only">{{ expandRowLabel }}</span>
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070045 </b-button>
46 </template>
47
48 <!-- Health -->
Derick Montague602e98a2020-10-21 16:20:00 -050049 <template #cell(health)="{ value }">
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070050 <status-icon :status="statusIcon(value)" />
51 {{ value }}
52 </template>
HuyLe5d86af82023-10-09 14:32:28 +070053
54 <!-- StatusState -->
55 <template #cell(statusState)="{ value }">
56 <status-icon :status="statusStateIcon(value)" />
57 {{ value }}
58 </template>
59
Sandeepa Singh81876782021-09-27 14:52:38 +053060 <!-- Toggle identify LED -->
61 <template #cell(identifyLed)="row">
62 <b-form-checkbox
Konstantin Aladyshevb24a4832022-11-02 17:32:04 +030063 v-if="hasIdentifyLed(row.item.identifyLed)"
Sandeepa Singh81876782021-09-27 14:52:38 +053064 v-model="row.item.identifyLed"
65 name="switch"
66 switch
67 @change="toggleIdentifyLedValue(row.item)"
68 >
69 <span v-if="row.item.identifyLed">
70 {{ $t('global.status.on') }}
71 </span>
72 <span v-else> {{ $t('global.status.off') }} </span>
73 </b-form-checkbox>
Konstantin Aladyshevb24a4832022-11-02 17:32:04 +030074 <div v-else>--</div>
Sandeepa Singh81876782021-09-27 14:52:38 +053075 </template>
Derick Montague602e98a2020-10-21 16:20:00 -050076 <template #row-details="{ item }">
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070077 <b-container fluid>
78 <b-row>
Sandeepa Singh81876782021-09-27 14:52:38 +053079 <b-col sm="6" xl="6">
Yoshie Muranakae24b17d2020-06-08 11:03:11 -070080 <dl>
Jason M. Billsaf76e2b2023-06-15 08:20:34 -070081 <!-- Manufacturer -->
82 <dt>{{ $t('pageInventory.table.manufacturer') }}:</dt>
83 <dd>{{ dataFormatter(item.manufacturer) }}</dd>
84 </dl>
85 <dl>
Sandeepa Singh81876782021-09-27 14:52:38 +053086 <!-- Part Number -->
87 <dt>{{ $t('pageInventory.table.partNumber') }}:</dt>
88 <dd>{{ dataFormatter(item.partNumber) }}</dd>
89 </dl>
90 <dl>
91 <!-- Serial Number -->
92 <dt>{{ $t('pageInventory.table.serialNumber') }}:</dt>
93 <dd>{{ dataFormatter(item.serialNumber) }}</dd>
94 </dl>
95 <dl>
96 <!-- Spare Part Number -->
97 <dt>{{ $t('pageInventory.table.sparePartNumber') }}:</dt>
98 <dd>{{ dataFormatter(item.sparePartNumber) }}</dd>
99 </dl>
100 <dl>
101 <!-- Model -->
102 <dt>{{ $t('pageInventory.table.model') }}:</dt>
103 <dd>{{ dataFormatter(item.model) }}</dd>
104 </dl>
Sandeepa Singh81876782021-09-27 14:52:38 +0530105 </b-col>
106 <b-col sm="6" xl="6">
107 <dl>
Glukhov Mikhailba60e9c2022-11-21 10:21:51 +0300108 <!-- Capacity MiB -->
109 <dt>{{ $t('pageInventory.table.capacityMiB') }}:</dt>
Glukhov Mikhaild0b078f2022-12-24 12:16:53 +0300110 <dd>
111 {{ dataFormatter(item.capacityMiB) }}
112 {{ $t('unit.MiB') }}
113 </dd>
Sandeepa Singh81876782021-09-27 14:52:38 +0530114 </dl>
115 <dl>
Jason M. Billsaf76e2b2023-06-15 08:20:34 -0700116 <!-- Rank Count -->
117 <dt>{{ $t('pageInventory.table.rankCount') }}:</dt>
118 <dd>{{ dataFormatter(item.rankCount) }}</dd>
119 </dl>
120 <dl>
Sandeepa Singh81876782021-09-27 14:52:38 +0530121 <!-- Status-->
Sandeepa Singh7affc522021-07-06 16:29:10 +0530122 <dt>{{ $t('pageInventory.table.statusState') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500123 <dd>{{ dataFormatter(item.statusState) }}</dd>
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700124 </dl>
Sandeepa Singh61fdd942021-12-27 17:40:32 +0530125 <dl>
126 <!-- Enabled-->
127 <dt>{{ $t('pageInventory.table.enabled') }}:</dt>
128 <dd>{{ dataFormatter(item.enabled) }}</dd>
129 </dl>
130 </b-col>
131 </b-row>
132 <div class="section-divider mb-3 mt-3"></div>
133 <b-row>
134 <b-col sm="6" xl="6">
135 <dl>
136 <!-- Description -->
137 <dt>{{ $t('pageInventory.table.description') }}:</dt>
138 <dd>{{ dataFormatter(item.description) }}</dd>
139 </dl>
140 <dl>
141 <!-- Memory Type -->
142 <dt>{{ $t('pageInventory.table.memoryType') }}:</dt>
143 <dd>{{ dataFormatter(item.memoryType) }}</dd>
144 </dl>
145 <dl>
146 <!-- Base Module Type -->
147 <dt>{{ $t('pageInventory.table.baseModuleType') }}:</dt>
148 <dd>{{ dataFormatter(item.baseModuleType) }}</dd>
149 </dl>
Sandeepa Singh61fdd942021-12-27 17:40:32 +0530150 </b-col>
151 <b-col sm="6" xl="6">
152 <dl>
153 <!-- Bus Width Bits -->
154 <dt>{{ $t('pageInventory.table.busWidthBits') }}:</dt>
Glukhov Mikhaild0b078f2022-12-24 12:16:53 +0300155 <dd>
156 {{ dataFormatter(item.busWidthBits) }}
157 {{ $t('unit.bit') }}
158 </dd>
Sandeepa Singh61fdd942021-12-27 17:40:32 +0530159 </dl>
160 <dl>
161 <!-- Data Width Bits -->
162 <dt>{{ $t('pageInventory.table.dataWidthBits') }}:</dt>
Glukhov Mikhaild0b078f2022-12-24 12:16:53 +0300163 <dd>
164 {{ dataFormatter(item.dataWidthBits) }}
165 {{ $t('unit.bit') }}
166 </dd>
Sandeepa Singh61fdd942021-12-27 17:40:32 +0530167 </dl>
168 <dl>
169 <!-- Operating Speed Mhz -->
170 <dt>{{ $t('pageInventory.table.operatingSpeedMhz') }}:</dt>
Glukhov Mikhaild0b078f2022-12-24 12:16:53 +0300171 <dd>
172 {{ dataFormatter(item.operatingSpeedMhz) }}
173 {{ $t('unit.MHz') }}
174 </dd>
Sandeepa Singh61fdd942021-12-27 17:40:32 +0530175 </dl>
Jason M. Billsaf76e2b2023-06-15 08:20:34 -0700176 <dl>
177 <!-- Error Correction -->
178 <dt>{{ $t('pageInventory.table.errorCorrection') }}:</dt>
179 <dd>{{ dataFormatter(item.errorCorrection) }}</dd>
180 </dl>
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700181 </b-col>
182 </b-row>
183 </b-container>
184 </template>
185 </b-table>
186 </page-section>
187</template>
188
189<script>
190import PageSection from '@/components/Global/PageSection';
191import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
192
193import StatusIcon from '@/components/Global/StatusIcon';
Sukanya Pandey99010962020-07-27 21:44:47 +0530194import TableCellCount from '@/components/Global/TableCellCount';
195
Nikhil Ashokaf11a1902024-05-09 15:17:44 +0530196import BVToastMixin from '@/components/Mixins/BVToastMixin';
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500197import DataFormatterMixin from '@/components/Mixins/DataFormatterMixin';
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700198import TableSortMixin from '@/components/Mixins/TableSortMixin';
Yoshie Muranaka41770142020-06-18 14:00:55 -0700199import Search from '@/components/Global/Search';
SurenNewareba91c492020-10-27 14:18:54 +0530200import SearchFilterMixin, {
201 searchFilter,
202} from '@/components/Mixins/SearchFilterMixin';
203import TableRowExpandMixin, {
204 expandRowLabel,
205} from '@/components/Mixins/TableRowExpandMixin';
Surya Vde23ea22024-07-11 15:19:46 +0530206import { useI18n } from 'vue-i18n';
207import i18n from '@/i18n';
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700208
209export default {
Sukanya Pandey99010962020-07-27 21:44:47 +0530210 components: { IconChevron, PageSection, StatusIcon, Search, TableCellCount },
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500211 mixins: [
Nikhil Ashokaf11a1902024-05-09 15:17:44 +0530212 BVToastMixin,
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500213 TableRowExpandMixin,
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500214 DataFormatterMixin,
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500215 TableSortMixin,
Derick Montague602e98a2020-10-21 16:20:00 -0500216 SearchFilterMixin,
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500217 ],
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700218 data() {
219 return {
Surya Vde23ea22024-07-11 15:19:46 +0530220 $t: useI18n().t,
Kenneth Fullbright41057852021-12-27 16:19:37 -0600221 isBusy: true,
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700222 fields: [
223 {
224 key: 'expandRow',
225 label: '',
226 tdClass: 'table-row-expand',
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700227 },
228 {
229 key: 'id',
Surya Vde23ea22024-07-11 15:19:46 +0530230 label: i18n.global.t('pageInventory.table.id'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500231 formatter: this.dataFormatter,
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700232 },
233 {
234 key: 'health',
Surya Vde23ea22024-07-11 15:19:46 +0530235 label: i18n.global.t('pageInventory.table.health'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500236 formatter: this.dataFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500237 tdClass: 'text-nowrap',
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700238 },
239 {
HuyLe5d86af82023-10-09 14:32:28 +0700240 key: 'statusState',
Surya Vde23ea22024-07-11 15:19:46 +0530241 label: i18n.global.t('pageInventory.table.state'),
HuyLe5d86af82023-10-09 14:32:28 +0700242 formatter: this.dataFormatter,
243 tdClass: 'text-nowrap',
244 },
245 {
Sandeepa Singh81876782021-09-27 14:52:38 +0530246 key: 'locationNumber',
Surya Vde23ea22024-07-11 15:19:46 +0530247 label: i18n.global.t('pageInventory.table.locationNumber'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500248 formatter: this.dataFormatter,
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700249 },
250 {
Sandeepa Singh81876782021-09-27 14:52:38 +0530251 key: 'identifyLed',
Surya Vde23ea22024-07-11 15:19:46 +0530252 label: i18n.global.t('pageInventory.table.identifyLed'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500253 formatter: this.dataFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500254 },
Yoshie Muranaka41770142020-06-18 14:00:55 -0700255 ],
SurenNewareba91c492020-10-27 14:18:54 +0530256 searchFilter: searchFilter,
Derick Montague602e98a2020-10-21 16:20:00 -0500257 searchTotalFilteredRows: 0,
SurenNewareba91c492020-10-27 14:18:54 +0530258 expandRowLabel: expandRowLabel,
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700259 };
260 },
261 computed: {
Sukanya Pandey99010962020-07-27 21:44:47 +0530262 filteredRows() {
263 return this.searchFilter
264 ? this.searchTotalFilteredRows
265 : this.dimms.length;
266 },
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700267 dimms() {
268 return this.$store.getters['memory/dimms'];
Derick Montague602e98a2020-10-21 16:20:00 -0500269 },
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700270 },
271 created() {
272 this.$store.dispatch('memory/getDimms').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500273 // Emit initial data fetch complete to parent component
Sukanya Pandeyedb8a772020-10-29 11:33:42 +0530274 this.$root.$emit('hardware-status-dimm-slot-complete');
Kenneth Fullbright41057852021-12-27 16:19:37 -0600275 this.isBusy = false;
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700276 });
277 },
278 methods: {
279 sortCompare(a, b, key) {
280 if (key === 'health') {
281 return this.sortStatus(a, b, key);
HuyLe5d86af82023-10-09 14:32:28 +0700282 } else if (key === 'statusState') {
283 return this.sortStatusState(a, b, key);
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700284 }
Yoshie Muranaka41770142020-06-18 14:00:55 -0700285 },
Sukanya Pandey99010962020-07-27 21:44:47 +0530286 onFiltered(filteredItems) {
287 this.searchTotalFilteredRows = filteredItems.length;
Derick Montague602e98a2020-10-21 16:20:00 -0500288 },
Sandeepa Singh81876782021-09-27 14:52:38 +0530289 toggleIdentifyLedValue(row) {
290 this.$store
291 .dispatch('memory/updateIdentifyLedValue', {
292 uri: row.uri,
293 identifyLed: row.identifyLed,
294 })
Nikhil Ashokaf11a1902024-05-09 15:17:44 +0530295 .then((message) => this.successToast(message))
Sandeepa Singh81876782021-09-27 14:52:38 +0530296 .catch(({ message }) => this.errorToast(message));
297 },
Konstantin Aladyshevb24a4832022-11-02 17:32:04 +0300298 hasIdentifyLed(identifyLed) {
299 return typeof identifyLed === 'boolean';
300 },
HuyLe5d86af82023-10-09 14:32:28 +0700301 statusStateIcon(status) {
302 switch (status) {
303 case 'Enabled':
304 return 'success';
305 case 'Absent':
306 return 'warning';
307 default:
308 return '';
309 }
310 },
311 sortStatusState(a, b, key) {
312 const statusState = ['Enabled', 'Absent'];
313 return statusState.indexOf(a[key]) - statusState.indexOf(b[key]);
314 },
Derick Montague602e98a2020-10-21 16:20:00 -0500315 },
Yoshie Muranakae24b17d2020-06-08 11:03:11 -0700316};
317</script>