blob: e267f7f38e5edf5edb7a4f28b08537ad27e1916f [file] [log] [blame]
Sneha Patela02c6f92021-09-09 12:40:38 -05001<template>
2 <page-section :section-title="$t('pageInventory.assemblies')">
3 <b-table
4 sort-icon-left
jason westoverd36ac8a2025-11-03 20:58:59 -06005 must-sort
Sneha Patela02c6f92021-09-09 12:40:38 -05006 hover
7 responsive="md"
jason westoverd36ac8a2025-11-03 20:58:59 -06008 thead-class="table-light"
Sneha Patela02c6f92021-09-09 12:40:38 -05009 :items="items"
10 :fields="fields"
11 show-empty
12 :empty-text="$t('global.table.emptyMessage')"
Kenneth Fullbright41057852021-12-27 16:19:37 -060013 :busy="isBusy"
Sneha Patela02c6f92021-09-09 12:40:38 -050014 >
15 <!-- Expand chevron icon -->
16 <template #cell(expandRow)="row">
17 <b-button
18 variant="link"
19 data-test-id="hardwareStatus-button-expandAssembly"
20 :title="expandRowLabel"
21 class="btn-icon-only"
jason westoverd36ac8a2025-11-03 20:58:59 -060022 :class="{ collapsed: !row.detailsShowing }"
Sneha Patela02c6f92021-09-09 12:40:38 -050023 @click="toggleRowDetails(row)"
24 >
25 <icon-chevron />
jason westoverd36ac8a2025-11-03 20:58:59 -060026 <span class="visually-hidden">{{ expandRowLabel }}</span>
Sneha Patela02c6f92021-09-09 12:40:38 -050027 </b-button>
28 </template>
29
30 <!-- Toggle identify LED -->
31 <template #cell(identifyLed)="row">
32 <b-form-checkbox
33 v-if="hasIdentifyLed(row.item.identifyLed)"
34 v-model="row.item.identifyLed"
35 name="switch"
36 switch
37 @change="toggleIdentifyLedValue(row.item)"
38 >
39 <span v-if="row.item.identifyLed">
40 {{ $t('global.status.on') }}
41 </span>
42 <span v-else> {{ $t('global.status.off') }} </span>
43 </b-form-checkbox>
44 <div v-else>--</div>
45 </template>
46
47 <template #row-details="{ item }">
48 <b-container fluid>
49 <b-row>
50 <b-col class="mt-2" sm="6" xl="6">
51 <!-- Nmae -->
52 <dt>{{ $t('pageInventory.table.name') }}:</dt>
Dixsie Wolmers75110452021-10-26 11:16:45 -050053 <dd>{{ dataFormatter(item.name) }}</dd>
Sneha Patela02c6f92021-09-09 12:40:38 -050054 <!-- Serial number -->
55 <dt>{{ $t('pageInventory.table.serialNumber') }}:</dt>
Dixsie Wolmers75110452021-10-26 11:16:45 -050056 <dd>{{ dataFormatter(item.serialNumber) }}</dd>
Sneha Patela02c6f92021-09-09 12:40:38 -050057 </b-col>
58 <b-col class="mt-2" sm="6" xl="6">
59 <!-- Model-->
60 <dt>Model</dt>
Dixsie Wolmers75110452021-10-26 11:16:45 -050061 <dd>{{ dataFormatter(item.model) }}</dd>
Sneha Patela02c6f92021-09-09 12:40:38 -050062 <!-- Spare Part Number -->
63 <dt>Spare Part Number</dt>
Dixsie Wolmers75110452021-10-26 11:16:45 -050064 <dd>{{ dataFormatter(item.sparePartNumber) }}</dd>
Sneha Patela02c6f92021-09-09 12:40:38 -050065 </b-col>
66 </b-row>
67 </b-container>
68 </template>
69 </b-table>
70 </page-section>
71</template>
72
73<script>
74import PageSection from '@/components/Global/PageSection';
75import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
76import BVToastMixin from '@/components/Mixins/BVToastMixin';
77import TableRowExpandMixin, {
78 expandRowLabel,
79} from '@/components/Mixins/TableRowExpandMixin';
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050080import DataFormatterMixin from '@/components/Mixins/DataFormatterMixin';
Surya Vde23ea22024-07-11 15:19:46 +053081import { useI18n } from 'vue-i18n';
82import i18n from '@/i18n';
Sneha Patela02c6f92021-09-09 12:40:38 -050083
84export default {
85 components: { IconChevron, PageSection },
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050086 mixins: [BVToastMixin, TableRowExpandMixin, DataFormatterMixin],
Sneha Patela02c6f92021-09-09 12:40:38 -050087 data() {
88 return {
Surya Vde23ea22024-07-11 15:19:46 +053089 $t: useI18n().t,
Kenneth Fullbright41057852021-12-27 16:19:37 -060090 isBusy: true,
Sneha Patela02c6f92021-09-09 12:40:38 -050091 fields: [
92 {
93 key: 'expandRow',
94 label: '',
95 tdClass: 'table-row-expand',
96 },
97 {
Kenneth Fullbright799bcd32021-12-17 10:28:45 -060098 key: 'name',
Surya Vde23ea22024-07-11 15:19:46 +053099 label: i18n.global.t('pageInventory.table.id'),
Dixsie Wolmers75110452021-10-26 11:16:45 -0500100 formatter: this.dataFormatter,
Sneha Patela02c6f92021-09-09 12:40:38 -0500101 sortable: true,
102 },
103 {
104 key: 'partNumber',
Surya Vde23ea22024-07-11 15:19:46 +0530105 label: i18n.global.t('pageInventory.table.partNumber'),
Dixsie Wolmers75110452021-10-26 11:16:45 -0500106 formatter: this.dataFormatter,
Sneha Patela02c6f92021-09-09 12:40:38 -0500107 sortable: true,
108 },
109 {
110 key: 'locationNumber',
Surya Vde23ea22024-07-11 15:19:46 +0530111 label: i18n.global.t('pageInventory.table.locationNumber'),
Dixsie Wolmers75110452021-10-26 11:16:45 -0500112 formatter: this.dataFormatter,
Sneha Patela02c6f92021-09-09 12:40:38 -0500113 sortable: true,
114 },
115 {
116 key: 'identifyLed',
Surya Vde23ea22024-07-11 15:19:46 +0530117 label: i18n.global.t('pageInventory.table.identifyLed'),
Dixsie Wolmers75110452021-10-26 11:16:45 -0500118 formatter: this.dataFormatter,
Sneha Patela02c6f92021-09-09 12:40:38 -0500119 },
120 ],
121 expandRowLabel: expandRowLabel,
122 };
123 },
124 computed: {
125 assemblies() {
126 return this.$store.getters['assemblies/assemblies'];
127 },
128 items() {
129 if (this.assemblies) {
130 return this.assemblies;
131 } else {
132 return [];
133 }
134 },
135 },
136 created() {
137 this.$store.dispatch('assemblies/getAssemblyInfo').finally(() => {
138 // Emit initial data fetch complete to parent component
jason westoverd36ac8a2025-11-03 20:58:59 -0600139 require('@/eventBus').default.$emit('hardware-status-assembly-complete');
Kenneth Fullbright41057852021-12-27 16:19:37 -0600140 this.isBusy = false;
Sneha Patela02c6f92021-09-09 12:40:38 -0500141 });
142 },
143 methods: {
144 toggleIdentifyLedValue(row) {
145 this.$store
146 .dispatch('assemblies/updateIdentifyLedValue', {
147 uri: row.uri,
Kenneth Fullbrightd600bb52021-12-20 17:01:31 -0600148 memberId: row.id,
Sneha Patela02c6f92021-09-09 12:40:38 -0500149 identifyLed: row.identifyLed,
150 })
Nikhil Ashokaf11a1902024-05-09 15:17:44 +0530151 .then((message) => this.successToast(message))
Sneha Patela02c6f92021-09-09 12:40:38 -0500152 .catch(({ message }) => this.errorToast(message));
153 },
154 hasIdentifyLed(identifyLed) {
155 return typeof identifyLed === 'boolean';
156 },
157 },
158};
159</script>