blob: 0d535027e2084e767cd74aaa615834d1dd36e910 [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')"
10 >
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -070011 <!-- Expand chevron icon -->
Derick Montague602e98a2020-10-21 16:20:00 -050012 <template #cell(expandRow)="row">
Dixsie Wolmers83133762020-07-15 08:45:19 -050013 <b-button
14 variant="link"
15 data-test-id="hardwareStatus-button-expandChassis"
Dixsie Wolmers30f11f82020-11-10 16:07:56 -060016 :title="expandRowLabel"
17 class="btn-icon-only"
Dixsie Wolmersb53e0862020-09-08 14:13:38 -050018 @click="toggleRowDetails(row)"
Dixsie Wolmers83133762020-07-15 08:45:19 -050019 >
Dixsie Wolmers30f11f82020-11-10 16:07:56 -060020 <icon-chevron />
SurenNeware6e2cb972020-12-24 20:58:16 +053021 <span class="sr-only">{{ expandRowLabel }}</span>
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -070022 </b-button>
23 </template>
24
25 <!-- Health -->
Derick Montague602e98a2020-10-21 16:20:00 -050026 <template #cell(health)="{ value }">
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -070027 <status-icon :status="statusIcon(value)" />
28 {{ value }}
29 </template>
Sandeepa Singh240c0562021-05-06 21:59:20 +053030 <!-- 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>
Derick Montague602e98a2020-10-21 16:20:00 -050046 <template #row-details="{ item }">
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -070047 <b-container fluid>
48 <b-row>
Sandeepa Singh240c0562021-05-06 21:59:20 +053049 <b-col class="mt-2" sm="6" xl="6">
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -070050 <dl>
Sandeepa Singh240c0562021-05-06 21:59:20 +053051 <!-- Name -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053052 <dt>{{ $t('pageInventory.table.name') }}:</dt>
Sandeepa Singh240c0562021-05-06 21:59:20 +053053 <dd>{{ tableFormatter(item.name) }}</dd>
54 <!-- Part number -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053055 <dt>{{ $t('pageInventory.table.partNumber') }}:</dt>
Sandeepa Singh240c0562021-05-06 21:59:20 +053056 <dd>{{ tableFormatter(item.partNumber) }}</dd>
57 <!-- Serial Number -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053058 <dt>{{ $t('pageInventory.table.serialNumber') }}:</dt>
Sandeepa Singh240c0562021-05-06 21:59:20 +053059 <dd>{{ tableFormatter(item.serialNumber) }}</dd>
60 <!-- Model -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053061 <dt>{{ $t('pageInventory.table.model') }}:</dt>
Sandeepa Singh240c0562021-05-06 21:59:20 +053062 <dd class="mb-2">
63 {{ tableFormatter(item.model) }}
64 </dd>
65 <!-- Asset tag -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053066 <dt>{{ $t('pageInventory.table.assetTag') }}:</dt>
Sandeepa Singh240c0562021-05-06 21:59:20 +053067 <dd class="mb-2">
68 {{ tableFormatter(item.assetTag) }}
69 </dd>
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -070070 </dl>
71 </b-col>
Sandeepa Singh240c0562021-05-06 21:59:20 +053072 <b-col class="mt-2" sm="6" xl="6">
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -070073 <dl>
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -070074 <!-- Status state -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053075 <dt>{{ $t('pageInventory.table.statusState') }}:</dt>
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -070076 <dd>{{ tableFormatter(item.statusState) }}</dd>
Sandeepa Singh240c0562021-05-06 21:59:20 +053077 <!-- Power state -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053078 <dt>{{ $t('pageInventory.table.power') }}:</dt>
Sandeepa Singh240c0562021-05-06 21:59:20 +053079 <dd>{{ tableFormatter(item.power) }}</dd>
80 <!-- Health rollup -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053081 <dt>{{ $t('pageInventory.table.healthRollup') }}:</dt>
Sandeepa Singh240c0562021-05-06 21:59:20 +053082 <dd>{{ tableFormatter(item.healthRollup) }}</dd>
83 </dl>
84 </b-col>
85 </b-row>
86 <div class="section-divider mb-3 mt-3"></div>
87 <b-row>
88 <b-col class="mt-2" sm="6" xl="6">
89 <dl>
90 <!-- Manufacturer -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053091 <dt>{{ $t('pageInventory.table.manufacturer') }}:</dt>
Sandeepa Singh240c0562021-05-06 21:59:20 +053092 <dd>{{ tableFormatter(item.manufacturer) }}</dd>
93 <!-- Chassis Type -->
Sandeepa Singh7affc522021-07-06 16:29:10 +053094 <dt>{{ $t('pageInventory.table.chassisType') }}:</dt>
Sandeepa Singh240c0562021-05-06 21:59:20 +053095 <dd>{{ tableFormatter(item.chassisType) }}</dd>
96 </dl>
97 </b-col>
98 <b-col class="mt-2" sm="6" xl="6">
99 <dl>
100 <!-- Min power -->
Sandeepa Singh7affc522021-07-06 16:29:10 +0530101 <dt>{{ $t('pageInventory.table.minPowerWatts') }}:</dt>
Sandeepa Singh240c0562021-05-06 21:59:20 +0530102 <dd>{{ tableFormatter(item.minPowerWatts) }}</dd>
103 <!-- Max power -->
Sandeepa Singh7affc522021-07-06 16:29:10 +0530104 <dt>{{ $t('pageInventory.table.maxPowerWatts') }}:</dt>
Sandeepa Singh240c0562021-05-06 21:59:20 +0530105 <dd>{{ tableFormatter(item.maxPowerWatts) }}</dd>
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700106 </dl>
107 </b-col>
108 </b-row>
109 </b-container>
110 </template>
111 </b-table>
112 </page-section>
113</template>
114
115<script>
116import PageSection from '@/components/Global/PageSection';
117import IconChevron from '@carbon/icons-vue/es/chevron--down/20';
Sandeepa Singh240c0562021-05-06 21:59:20 +0530118import BVToastMixin from '@/components/Mixins/BVToastMixin';
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700119import StatusIcon from '@/components/Global/StatusIcon';
Dixsie Wolmersb53e0862020-09-08 14:13:38 -0500120
SurenNewareba91c492020-10-27 14:18:54 +0530121import TableRowExpandMixin, {
122 expandRowLabel,
123} from '@/components/Mixins/TableRowExpandMixin';
Yoshie Muranaka386df452020-06-18 12:45:13 -0700124import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin';
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700125
126export default {
127 components: { IconChevron, PageSection, StatusIcon },
Sandeepa Singh240c0562021-05-06 21:59:20 +0530128 mixins: [BVToastMixin, TableRowExpandMixin, TableDataFormatterMixin],
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700129 data() {
130 return {
131 fields: [
132 {
133 key: 'expandRow',
134 label: '',
Derick Montague602e98a2020-10-21 16:20:00 -0500135 tdClass: 'table-row-expand',
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700136 },
137 {
138 key: 'id',
Sandeepa Singh7affc522021-07-06 16:29:10 +0530139 label: this.$t('pageInventory.table.id'),
Derick Montague602e98a2020-10-21 16:20:00 -0500140 formatter: this.tableFormatter,
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700141 },
142 {
143 key: 'health',
Sandeepa Singh7affc522021-07-06 16:29:10 +0530144 label: this.$t('pageInventory.table.health'),
Dixsie Wolmersa04d46f2020-10-22 06:34:56 -0500145 formatter: this.tableFormatter,
Derick Montague602e98a2020-10-21 16:20:00 -0500146 tdClass: 'text-nowrap',
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700147 },
148 {
Sandeepa Singh240c0562021-05-06 21:59:20 +0530149 key: 'locationNumber',
Sandeepa Singh7affc522021-07-06 16:29:10 +0530150 label: this.$t('pageInventory.table.locationNumber'),
Derick Montague602e98a2020-10-21 16:20:00 -0500151 formatter: this.tableFormatter,
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700152 },
153 {
Sandeepa Singh240c0562021-05-06 21:59:20 +0530154 key: 'identifyLed',
Sandeepa Singh7affc522021-07-06 16:29:10 +0530155 label: this.$t('pageInventory.table.identifyLed'),
Derick Montague602e98a2020-10-21 16:20:00 -0500156 formatter: this.tableFormatter,
157 },
158 ],
SurenNewareba91c492020-10-27 14:18:54 +0530159 expandRowLabel: expandRowLabel,
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700160 };
161 },
162 computed: {
163 chassis() {
164 return this.$store.getters['chassis/chassis'];
Derick Montague602e98a2020-10-21 16:20:00 -0500165 },
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700166 },
167 created() {
168 this.$store.dispatch('chassis/getChassisInfo').finally(() => {
Gunnar Millsdefc9e22020-07-07 20:29:03 -0500169 // Emit initial data fetch complete to parent component
Sukanya Pandeyedb8a772020-10-29 11:33:42 +0530170 this.$root.$emit('hardware-status-chassis-complete');
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700171 });
Derick Montague602e98a2020-10-21 16:20:00 -0500172 },
Sandeepa Singh240c0562021-05-06 21:59:20 +0530173 methods: {
174 toggleIdentifyLedValue(row) {
175 this.$store
176 .dispatch('chassis/updateIdentifyLedValue', {
177 uri: row.uri,
178 identifyLed: row.identifyLed,
179 })
180 .catch(({ message }) => this.errorToast(message));
181 },
182 // TO DO: Remove this method when the LocationIndicatorActive is added from backend.
183 hasIdentifyLed(identifyLed) {
184 return typeof identifyLed === 'boolean';
185 },
186 },
Yoshie Muranaka09e8b5d2020-06-08 07:36:59 -0700187};
188</script>