blob: 4c557fa24823768ab71f2a0ff302b9a3dad7d09a [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
SurenNeware307382e2020-07-27 20:45:14 +05306 :items="chassis"
7 :fields="fields"
8 show-empty
9 :empty-text="$t('global.table.emptyMessage')"
Kenneth Fullbright41057852021-12-27 16:19:37 -060010 :busy="isBusy"
SurenNeware307382e2020-07-27 20:45:14 +053011 >
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -070012 <!-- Expand chevron icon -->
Derick Montague602e98a2020-10-21 16:20:00 -050013 <template #cell(expandRow)="row">
Dixsie Wolmers83133762020-07-15 08:45:19 -050014 <b-button
15 variant="link"
16 data-test-id="hardwareStatus-button-expandChassis"
Dixsie Wolmers30f11f82020-11-10 16:07:56 -060017 :title="expandRowLabel"
18 class="btn-icon-only"
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050019 @click="toggleRowDetails(row)"
Dixsie Wolmers83133762020-07-15 08:45:19 -050020 >
Dixsie Wolmers30f11f82020-11-10 16:07:56 -060021 <icon-chevron />
SurenNeware6e2cb972020-12-24 20:58:16 +053022 <span class="sr-only">{{ expandRowLabel }}</span>
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -070023 </b-button>
24 </template>
25
26 <!-- Health -->
Derick Montague602e98a2020-10-21 16:20:00 -050027 <template #cell(health)="{ value }">
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -070028 <status-icon :status="statusIcon(value)" />
29 {{ value }}
30 </template>
Sandeepa Singh240c0562021-05-06 21:59:20 +053031 <!-- Toggle identify LED -->
32 <template #cell(identifyLed)="row">
33 <b-form-checkbox
34 v-if="hasIdentifyLed(row.item.identifyLed)"
35 v-model="row.item.identifyLed"
36 name="switch"
37 switch
38 @change="toggleIdentifyLedValue(row.item)"
39 >
40 <span v-if="row.item.identifyLed">
41 {{ $t('global.status.on') }}
42 </span>
43 <span v-else> {{ $t('global.status.off') }} </span>
44 </b-form-checkbox>
45 <div v-else>--</div>
46 </template>
Derick Montague602e98a2020-10-21 16:20:00 -050047 <template #row-details="{ item }">
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -070048 <b-container fluid>
49 <b-row>
Sandeepa Singh240c0562021-05-06 21:59:20 +053050 <b-col class="mt-2" sm="6" xl="6">
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -070051 <dl>
Sandeepa Singh240c0562021-05-06 21:59:20 +053052 <!-- Name -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053053 <dt>{{ $t('pageInventory.table.name') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050054 <dd>{{ dataFormatter(item.name) }}</dd>
Sandeepa Singh240c0562021-05-06 21:59:20 +053055 <!-- Part number -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053056 <dt>{{ $t('pageInventory.table.partNumber') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050057 <dd>{{ dataFormatter(item.partNumber) }}</dd>
Sandeepa Singh240c0562021-05-06 21:59:20 +053058 <!-- Serial Number -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053059 <dt>{{ $t('pageInventory.table.serialNumber') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050060 <dd>{{ dataFormatter(item.serialNumber) }}</dd>
Sandeepa Singh240c0562021-05-06 21:59:20 +053061 <!-- Model -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053062 <dt>{{ $t('pageInventory.table.model') }}:</dt>
Sandeepa Singh240c0562021-05-06 21:59:20 +053063 <dd class="mb-2">
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050064 {{ dataFormatter(item.model) }}
Sandeepa Singh240c0562021-05-06 21:59:20 +053065 </dd>
66 <!-- Asset tag -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053067 <dt>{{ $t('pageInventory.table.assetTag') }}:</dt>
Sandeepa Singh240c0562021-05-06 21:59:20 +053068 <dd class="mb-2">
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050069 {{ dataFormatter(item.assetTag) }}
Sandeepa Singh240c0562021-05-06 21:59:20 +053070 </dd>
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -070071 </dl>
72 </b-col>
Sandeepa Singh240c0562021-05-06 21:59:20 +053073 <b-col class="mt-2" sm="6" xl="6">
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -070074 <dl>
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -070075 <!-- Status state -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053076 <dt>{{ $t('pageInventory.table.statusState') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050077 <dd>{{ dataFormatter(item.statusState) }}</dd>
Sandeepa Singh240c0562021-05-06 21:59:20 +053078 <!-- Power state -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053079 <dt>{{ $t('pageInventory.table.power') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050080 <dd>{{ dataFormatter(item.power) }}</dd>
Sandeepa Singh240c0562021-05-06 21:59:20 +053081 <!-- Health rollup -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053082 <dt>{{ $t('pageInventory.table.healthRollup') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050083 <dd>{{ dataFormatter(item.healthRollup) }}</dd>
Sandeepa Singh240c0562021-05-06 21:59:20 +053084 </dl>
85 </b-col>
86 </b-row>
87 <div class="section-divider mb-3 mt-3"></div>
88 <b-row>
89 <b-col class="mt-2" sm="6" xl="6">
90 <dl>
91 <!-- Manufacturer -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053092 <dt>{{ $t('pageInventory.table.manufacturer') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050093 <dd>{{ dataFormatter(item.manufacturer) }}</dd>
Sandeepa Singh240c0562021-05-06 21:59:20 +053094 <!-- Chassis Type -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053095 <dt>{{ $t('pageInventory.table.chassisType') }}:</dt>
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -050096 <dd>{{ dataFormatter(item.chassisType) }}</dd>
Sandeepa Singh240c0562021-05-06 21:59:20 +053097 </dl>
98 </b-col>
99 <b-col class="mt-2" sm="6" xl="6">
100 <dl>
101 <!-- Min power -->
Sandeepa Singh7affc522021-07-06 16:29:10 +0530102 <dt>{{ $t('pageInventory.table.minPowerWatts') }}:</dt>
Glukhov Mikhaild0b078f2022-12-24 12:16:53 +0300103 <dd>
104 {{ dataFormatter(item.minPowerWatts) }}
105 {{ $t('unit.W') }}
106 </dd>
Sandeepa Singh240c0562021-05-06 21:59:20 +0530107 <!-- Max power -->
Sandeepa Singh7affc522021-07-06 16:29:10 +0530108 <dt>{{ $t('pageInventory.table.maxPowerWatts') }}:</dt>
Glukhov Mikhaild0b078f2022-12-24 12:16:53 +0300109 <dd>
110 {{ dataFormatter(item.maxPowerWatts) }}
111 {{ $t('unit.W') }}
112 </dd>
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700113 </dl>
114 </b-col>
115 </b-row>
116 </b-container>
117 </template>
118 </b-table>
119 </page-section>
120</template>
121
122<script>
123import PageSection from '@/components/Global/PageSection';
124import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
Sandeepa Singh240c0562021-05-06 21:59:20 +0530125import BVToastMixin from '@/components/Mixins/BVToastMixin';
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700126import StatusIcon from '@/components/Global/StatusIcon';
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500127
SurenNewareba91c492020-10-27 14:18:54 +0530128import TableRowExpandMixin, {
129 expandRowLabel,
130} from '@/components/Mixins/TableRowExpandMixin';
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500131import DataFormatterMixin from '@/components/Mixins/DataFormatterMixin';
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700132
133export default {
134 components: { IconChevron, PageSection, StatusIcon },
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500135 mixins: [BVToastMixin, TableRowExpandMixin, DataFormatterMixin],
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700136 data() {
137 return {
Kenneth Fullbright41057852021-12-27 16:19:37 -0600138 isBusy: true,
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700139 fields: [
140 {
141 key: 'expandRow',
142 label: '',
Derick Montague602e98a2020-10-21 16:20:00 -0500143 tdClass: 'table-row-expand',
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700144 },
145 {
146 key: 'id',
Sandeepa Singh7affc522021-07-06 16:29:10 +0530147 label: this.$t('pageInventory.table.id'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500148 formatter: this.dataFormatter,
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700149 },
150 {
151 key: 'health',
Sandeepa Singh7affc522021-07-06 16:29:10 +0530152 label: this.$t('pageInventory.table.health'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500153 formatter: this.dataFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500154 tdClass: 'text-nowrap',
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700155 },
156 {
Sandeepa Singh240c0562021-05-06 21:59:20 +0530157 key: 'locationNumber',
Sandeepa Singh7affc522021-07-06 16:29:10 +0530158 label: this.$t('pageInventory.table.locationNumber'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500159 formatter: this.dataFormatter,
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700160 },
161 {
Sandeepa Singh240c0562021-05-06 21:59:20 +0530162 key: 'identifyLed',
Sandeepa Singh7affc522021-07-06 16:29:10 +0530163 label: this.$t('pageInventory.table.identifyLed'),
Dixsie Wolmers9726f9a2021-09-07 15:33:16 -0500164 formatter: this.dataFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500165 },
166 ],
SurenNewareba91c492020-10-27 14:18:54 +0530167 expandRowLabel: expandRowLabel,
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700168 };
169 },
170 computed: {
171 chassis() {
172 return this.$store.getters['chassis/chassis'];
Derick Montague602e98a2020-10-21 16:20:00 -0500173 },
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700174 },
175 created() {
176 this.$store.dispatch('chassis/getChassisInfo').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500177 // Emit initial data fetch complete to parent component
Sukanya Pandeyedb8a772020-10-29 11:33:42 +0530178 this.$root.$emit('hardware-status-chassis-complete');
Kenneth Fullbright41057852021-12-27 16:19:37 -0600179 this.isBusy = false;
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700180 });
Derick Montague602e98a2020-10-21 16:20:00 -0500181 },
Sandeepa Singh240c0562021-05-06 21:59:20 +0530182 methods: {
183 toggleIdentifyLedValue(row) {
184 this.$store
185 .dispatch('chassis/updateIdentifyLedValue', {
186 uri: row.uri,
187 identifyLed: row.identifyLed,
188 })
189 .catch(({ message }) => this.errorToast(message));
190 },
191 // TO DO: Remove this method when the LocationIndicatorActive is added from backend.
192 hasIdentifyLed(identifyLed) {
193 return typeof identifyLed === 'boolean';
194 },
195 },
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700196};
197</script>