blob: 8278e52ee0ac6ed792dd194991c48bd24954d850 [file] [log] [blame]
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -07001<template>
Sandeepa Singh7affc522021-07-06 16:29:10 +05302 <page-section :section-title="$t('pageInventory.chassis')">
SurenNeware307382e2020-07-27 20:45:14 +05303 <b-table
4 responsive="md"
Sukanya Pandeyfde429e2020-09-14 20:48:39 +05305 hover
jason westoverd36ac8a2025-11-03 20:58:59 -06006 thead-class="table-light"
SurenNeware307382e2020-07-27 20:45:14 +05307 :items="chassis"
8 :fields="fields"
9 show-empty
10 :empty-text="$t('global.table.emptyMessage')"
Kenneth Fullbright41057852021-12-27 16:19:37 -060011 :busy="isBusy"
SurenNeware307382e2020-07-27 20:45:14 +053012 >
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -070013 <!-- Expand chevron icon -->
Derick Montague602e98a2020-10-21 16:20:00 -050014 <template #cell(expandRow)="row">
Dixsie Wolmers83133762020-07-15 08:45:19 -050015 <b-button
16 variant="link"
17 data-test-id="hardwareStatus-button-expandChassis"
Dixsie Wolmers30f11f82020-11-10 16:07:56 -060018 :title="expandRowLabel"
19 class="btn-icon-only"
jason westoverd36ac8a2025-11-03 20:58:59 -060020 :class="{ collapsed: !row.detailsShowing }"
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050021 @click="toggleRowDetails(row)"
Dixsie Wolmers83133762020-07-15 08:45:19 -050022 >
Dixsie Wolmers30f11f82020-11-10 16:07:56 -060023 <icon-chevron />
jason westoverd36ac8a2025-11-03 20:58:59 -060024 <span class="visually-hidden">{{ expandRowLabel }}</span>
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -070025 </b-button>
26 </template>
27
28 <!-- Health -->
Derick Montague602e98a2020-10-21 16:20:00 -050029 <template #cell(health)="{ value }">
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -070030 <status-icon :status="statusIcon(value)" />
31 {{ value }}
32 </template>
Sandeepa Singh240c0562021-05-06 21:59:20 +053033 <!-- Toggle identify LED -->
34 <template #cell(identifyLed)="row">
35 <b-form-checkbox
36 v-if="hasIdentifyLed(row.item.identifyLed)"
37 v-model="row.item.identifyLed"
38 name="switch"
39 switch
40 @change="toggleIdentifyLedValue(row.item)"
41 >
42 <span v-if="row.item.identifyLed">
43 {{ $t('global.status.on') }}
44 </span>
45 <span v-else> {{ $t('global.status.off') }} </span>
46 </b-form-checkbox>
47 <div v-else>--</div>
48 </template>
Derick Montague602e98a2020-10-21 16:20:00 -050049 <template #row-details="{ item }">
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -070050 <b-container fluid>
51 <b-row>
Sandeepa Singh240c0562021-05-06 21:59:20 +053052 <b-col class="mt-2" sm="6" xl="6">
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -070053 <dl>
Sandeepa Singh240c0562021-05-06 21:59:20 +053054 <!-- Name -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053055 <dt>{{ $t('pageInventory.table.name') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050056 <dd>{{ dataFormatter(item.name) }}</dd>
Sandeepa Singh240c0562021-05-06 21:59:20 +053057 <!-- Part number -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053058 <dt>{{ $t('pageInventory.table.partNumber') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050059 <dd>{{ dataFormatter(item.partNumber) }}</dd>
Sandeepa Singh240c0562021-05-06 21:59:20 +053060 <!-- Serial Number -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053061 <dt>{{ $t('pageInventory.table.serialNumber') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050062 <dd>{{ dataFormatter(item.serialNumber) }}</dd>
Sandeepa Singh240c0562021-05-06 21:59:20 +053063 <!-- Model -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053064 <dt>{{ $t('pageInventory.table.model') }}:</dt>
Sandeepa Singh240c0562021-05-06 21:59:20 +053065 <dd class="mb-2">
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050066 {{ dataFormatter(item.model) }}
Sandeepa Singh240c0562021-05-06 21:59:20 +053067 </dd>
68 <!-- Asset tag -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053069 <dt>{{ $t('pageInventory.table.assetTag') }}:</dt>
Sandeepa Singh240c0562021-05-06 21:59:20 +053070 <dd class="mb-2">
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050071 {{ dataFormatter(item.assetTag) }}
Sandeepa Singh240c0562021-05-06 21:59:20 +053072 </dd>
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -070073 </dl>
74 </b-col>
Sandeepa Singh240c0562021-05-06 21:59:20 +053075 <b-col class="mt-2" sm="6" xl="6">
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -070076 <dl>
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -070077 <!-- Status state -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053078 <dt>{{ $t('pageInventory.table.statusState') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050079 <dd>{{ dataFormatter(item.statusState) }}</dd>
Sandeepa Singh240c0562021-05-06 21:59:20 +053080 <!-- Power state -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053081 <dt>{{ $t('pageInventory.table.power') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050082 <dd>{{ dataFormatter(item.power) }}</dd>
Sandeepa Singh240c0562021-05-06 21:59:20 +053083 <!-- Health rollup -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053084 <dt>{{ $t('pageInventory.table.healthRollup') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050085 <dd>{{ dataFormatter(item.healthRollup) }}</dd>
Sandeepa Singh240c0562021-05-06 21:59:20 +053086 </dl>
87 </b-col>
88 </b-row>
89 <div class="section-divider mb-3 mt-3"></div>
90 <b-row>
91 <b-col class="mt-2" sm="6" xl="6">
92 <dl>
93 <!-- Manufacturer -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053094 <dt>{{ $t('pageInventory.table.manufacturer') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050095 <dd>{{ dataFormatter(item.manufacturer) }}</dd>
Sandeepa Singh240c0562021-05-06 21:59:20 +053096 <!-- Chassis Type -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053097 <dt>{{ $t('pageInventory.table.chassisType') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050098 <dd>{{ dataFormatter(item.chassisType) }}</dd>
Sandeepa Singh240c0562021-05-06 21:59:20 +053099 </dl>
100 </b-col>
101 <b-col class="mt-2" sm="6" xl="6">
102 <dl>
103 <!-- Min power -->
Sandeepa Singh7affc522021-07-06 16:29:10 +0530104 <dt>{{ $t('pageInventory.table.minPowerWatts') }}:</dt>
Glukhov Mikhaild0b078f2022-12-24 12:16:53 +0300105 <dd>
106 {{ dataFormatter(item.minPowerWatts) }}
107 {{ $t('unit.W') }}
108 </dd>
Sandeepa Singh240c0562021-05-06 21:59:20 +0530109 <!-- Max power -->
Sandeepa Singh7affc522021-07-06 16:29:10 +0530110 <dt>{{ $t('pageInventory.table.maxPowerWatts') }}:</dt>
Glukhov Mikhaild0b078f2022-12-24 12:16:53 +0300111 <dd>
112 {{ dataFormatter(item.maxPowerWatts) }}
113 {{ $t('unit.W') }}
114 </dd>
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700115 </dl>
116 </b-col>
117 </b-row>
118 </b-container>
119 </template>
120 </b-table>
121 </page-section>
122</template>
123
124<script>
125import PageSection from '@/components/Global/PageSection';
126import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
Sandeepa Singh240c0562021-05-06 21:59:20 +0530127import BVToastMixin from '@/components/Mixins/BVToastMixin';
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700128import StatusIcon from '@/components/Global/StatusIcon';
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500129
SurenNewareba91c492020-10-27 14:18:54 +0530130import TableRowExpandMixin, {
131 expandRowLabel,
132} from '@/components/Mixins/TableRowExpandMixin';
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500133import DataFormatterMixin from '@/components/Mixins/DataFormatterMixin';
Surya Vde23ea22024-07-11 15:19:46 +0530134import { useI18n } from 'vue-i18n';
135import i18n from '@/i18n';
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700136
137export default {
138 components: { IconChevron, PageSection, StatusIcon },
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500139 mixins: [BVToastMixin, TableRowExpandMixin, DataFormatterMixin],
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700140 data() {
141 return {
Surya Vde23ea22024-07-11 15:19:46 +0530142 $t: useI18n().t,
Kenneth Fullbright41057852021-12-27 16:19:37 -0600143 isBusy: true,
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700144 fields: [
145 {
146 key: 'expandRow',
147 label: '',
Derick Montague602e98a2020-10-21 16:20:00 -0500148 tdClass: 'table-row-expand',
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700149 },
150 {
151 key: 'id',
Surya Vde23ea22024-07-11 15:19:46 +0530152 label: i18n.global.t('pageInventory.table.id'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500153 formatter: this.dataFormatter,
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700154 },
155 {
156 key: 'health',
Surya Vde23ea22024-07-11 15:19:46 +0530157 label: i18n.global.t('pageInventory.table.health'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500158 formatter: this.dataFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500159 tdClass: 'text-nowrap',
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700160 },
161 {
Sandeepa Singh240c0562021-05-06 21:59:20 +0530162 key: 'locationNumber',
Surya Vde23ea22024-07-11 15:19:46 +0530163 label: i18n.global.t('pageInventory.table.locationNumber'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500164 formatter: this.dataFormatter,
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700165 },
166 {
Sandeepa Singh240c0562021-05-06 21:59:20 +0530167 key: 'identifyLed',
Surya Vde23ea22024-07-11 15:19:46 +0530168 label: i18n.global.t('pageInventory.table.identifyLed'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500169 formatter: this.dataFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500170 },
171 ],
SurenNewareba91c492020-10-27 14:18:54 +0530172 expandRowLabel: expandRowLabel,
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700173 };
174 },
175 computed: {
176 chassis() {
177 return this.$store.getters['chassis/chassis'];
Derick Montague602e98a2020-10-21 16:20:00 -0500178 },
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700179 },
180 created() {
181 this.$store.dispatch('chassis/getChassisInfo').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500182 // Emit initial data fetch complete to parent component
jason westoverd36ac8a2025-11-03 20:58:59 -0600183 require('@/eventBus').default.$emit('hardware-status-chassis-complete');
Kenneth Fullbright41057852021-12-27 16:19:37 -0600184 this.isBusy = false;
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700185 });
Derick Montague602e98a2020-10-21 16:20:00 -0500186 },
Sandeepa Singh240c0562021-05-06 21:59:20 +0530187 methods: {
188 toggleIdentifyLedValue(row) {
189 this.$store
190 .dispatch('chassis/updateIdentifyLedValue', {
191 uri: row.uri,
192 identifyLed: row.identifyLed,
193 })
Nikhil Ashokaf11a1902024-05-09 15:17:44 +0530194 .then((message) => this.successToast(message))
Sandeepa Singh240c0562021-05-06 21:59:20 +0530195 .catch(({ message }) => this.errorToast(message));
196 },
197 // TO DO: Remove this method when the LocationIndicatorActive is added from backend.
198 hasIdentifyLed(identifyLed) {
199 return typeof identifyLed === 'boolean';
200 },
201 },
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700202};
203</script>