Yoshie Muranaka | 09e8b5d | 2020-06-08 07:36:59 -0700 | [diff] [blame] | 1 | <template> |
Sandeepa Singh | 7affc52 | 2021-07-06 16:29:10 +0530 | [diff] [blame] | 2 | <page-section :section-title="$t('pageInventory.chassis')"> |
SurenNeware | 307382e | 2020-07-27 20:45:14 +0530 | [diff] [blame] | 3 | <b-table |
| 4 | responsive="md" |
Sukanya Pandey | fde429e | 2020-09-14 20:48:39 +0530 | [diff] [blame] | 5 | hover |
SurenNeware | 307382e | 2020-07-27 20:45:14 +0530 | [diff] [blame] | 6 | :items="chassis" |
| 7 | :fields="fields" |
| 8 | show-empty |
| 9 | :empty-text="$t('global.table.emptyMessage')" |
| 10 | > |
Yoshie Muranaka | 09e8b5d | 2020-06-08 07:36:59 -0700 | [diff] [blame] | 11 | <!-- Expand chevron icon --> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 12 | <template #cell(expandRow)="row"> |
Dixsie Wolmers | 8313376 | 2020-07-15 08:45:19 -0500 | [diff] [blame] | 13 | <b-button |
| 14 | variant="link" |
| 15 | data-test-id="hardwareStatus-button-expandChassis" |
Dixsie Wolmers | 30f11f8 | 2020-11-10 16:07:56 -0600 | [diff] [blame] | 16 | :title="expandRowLabel" |
| 17 | class="btn-icon-only" |
Dixsie Wolmers | b53e086 | 2020-09-08 14:13:38 -0500 | [diff] [blame] | 18 | @click="toggleRowDetails(row)" |
Dixsie Wolmers | 8313376 | 2020-07-15 08:45:19 -0500 | [diff] [blame] | 19 | > |
Dixsie Wolmers | 30f11f8 | 2020-11-10 16:07:56 -0600 | [diff] [blame] | 20 | <icon-chevron /> |
SurenNeware | 6e2cb97 | 2020-12-24 20:58:16 +0530 | [diff] [blame] | 21 | <span class="sr-only">{{ expandRowLabel }}</span> |
Yoshie Muranaka | 09e8b5d | 2020-06-08 07:36:59 -0700 | [diff] [blame] | 22 | </b-button> |
| 23 | </template> |
| 24 | |
| 25 | <!-- Health --> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 26 | <template #cell(health)="{ value }"> |
Yoshie Muranaka | 09e8b5d | 2020-06-08 07:36:59 -0700 | [diff] [blame] | 27 | <status-icon :status="statusIcon(value)" /> |
| 28 | {{ value }} |
| 29 | </template> |
Sandeepa Singh | 240c056 | 2021-05-06 21:59:20 +0530 | [diff] [blame] | 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> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 46 | <template #row-details="{ item }"> |
Yoshie Muranaka | 09e8b5d | 2020-06-08 07:36:59 -0700 | [diff] [blame] | 47 | <b-container fluid> |
| 48 | <b-row> |
Sandeepa Singh | 240c056 | 2021-05-06 21:59:20 +0530 | [diff] [blame] | 49 | <b-col class="mt-2" sm="6" xl="6"> |
Yoshie Muranaka | 09e8b5d | 2020-06-08 07:36:59 -0700 | [diff] [blame] | 50 | <dl> |
Sandeepa Singh | 240c056 | 2021-05-06 21:59:20 +0530 | [diff] [blame] | 51 | <!-- Name --> |
Sandeepa Singh | 7affc52 | 2021-07-06 16:29:10 +0530 | [diff] [blame] | 52 | <dt>{{ $t('pageInventory.table.name') }}:</dt> |
Sandeepa Singh | 240c056 | 2021-05-06 21:59:20 +0530 | [diff] [blame] | 53 | <dd>{{ tableFormatter(item.name) }}</dd> |
| 54 | <!-- Part number --> |
Sandeepa Singh | 7affc52 | 2021-07-06 16:29:10 +0530 | [diff] [blame] | 55 | <dt>{{ $t('pageInventory.table.partNumber') }}:</dt> |
Sandeepa Singh | 240c056 | 2021-05-06 21:59:20 +0530 | [diff] [blame] | 56 | <dd>{{ tableFormatter(item.partNumber) }}</dd> |
| 57 | <!-- Serial Number --> |
Sandeepa Singh | 7affc52 | 2021-07-06 16:29:10 +0530 | [diff] [blame] | 58 | <dt>{{ $t('pageInventory.table.serialNumber') }}:</dt> |
Sandeepa Singh | 240c056 | 2021-05-06 21:59:20 +0530 | [diff] [blame] | 59 | <dd>{{ tableFormatter(item.serialNumber) }}</dd> |
| 60 | <!-- Model --> |
Sandeepa Singh | 7affc52 | 2021-07-06 16:29:10 +0530 | [diff] [blame] | 61 | <dt>{{ $t('pageInventory.table.model') }}:</dt> |
Sandeepa Singh | 240c056 | 2021-05-06 21:59:20 +0530 | [diff] [blame] | 62 | <dd class="mb-2"> |
| 63 | {{ tableFormatter(item.model) }} |
| 64 | </dd> |
| 65 | <!-- Asset tag --> |
Sandeepa Singh | 7affc52 | 2021-07-06 16:29:10 +0530 | [diff] [blame] | 66 | <dt>{{ $t('pageInventory.table.assetTag') }}:</dt> |
Sandeepa Singh | 240c056 | 2021-05-06 21:59:20 +0530 | [diff] [blame] | 67 | <dd class="mb-2"> |
| 68 | {{ tableFormatter(item.assetTag) }} |
| 69 | </dd> |
Yoshie Muranaka | 09e8b5d | 2020-06-08 07:36:59 -0700 | [diff] [blame] | 70 | </dl> |
| 71 | </b-col> |
Sandeepa Singh | 240c056 | 2021-05-06 21:59:20 +0530 | [diff] [blame] | 72 | <b-col class="mt-2" sm="6" xl="6"> |
Yoshie Muranaka | 09e8b5d | 2020-06-08 07:36:59 -0700 | [diff] [blame] | 73 | <dl> |
Yoshie Muranaka | 09e8b5d | 2020-06-08 07:36:59 -0700 | [diff] [blame] | 74 | <!-- Status state --> |
Sandeepa Singh | 7affc52 | 2021-07-06 16:29:10 +0530 | [diff] [blame] | 75 | <dt>{{ $t('pageInventory.table.statusState') }}:</dt> |
Yoshie Muranaka | 09e8b5d | 2020-06-08 07:36:59 -0700 | [diff] [blame] | 76 | <dd>{{ tableFormatter(item.statusState) }}</dd> |
Sandeepa Singh | 240c056 | 2021-05-06 21:59:20 +0530 | [diff] [blame] | 77 | <!-- Power state --> |
Sandeepa Singh | 7affc52 | 2021-07-06 16:29:10 +0530 | [diff] [blame] | 78 | <dt>{{ $t('pageInventory.table.power') }}:</dt> |
Sandeepa Singh | 240c056 | 2021-05-06 21:59:20 +0530 | [diff] [blame] | 79 | <dd>{{ tableFormatter(item.power) }}</dd> |
| 80 | <!-- Health rollup --> |
Sandeepa Singh | 7affc52 | 2021-07-06 16:29:10 +0530 | [diff] [blame] | 81 | <dt>{{ $t('pageInventory.table.healthRollup') }}:</dt> |
Sandeepa Singh | 240c056 | 2021-05-06 21:59:20 +0530 | [diff] [blame] | 82 | <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 Singh | 7affc52 | 2021-07-06 16:29:10 +0530 | [diff] [blame] | 91 | <dt>{{ $t('pageInventory.table.manufacturer') }}:</dt> |
Sandeepa Singh | 240c056 | 2021-05-06 21:59:20 +0530 | [diff] [blame] | 92 | <dd>{{ tableFormatter(item.manufacturer) }}</dd> |
| 93 | <!-- Chassis Type --> |
Sandeepa Singh | 7affc52 | 2021-07-06 16:29:10 +0530 | [diff] [blame] | 94 | <dt>{{ $t('pageInventory.table.chassisType') }}:</dt> |
Sandeepa Singh | 240c056 | 2021-05-06 21:59:20 +0530 | [diff] [blame] | 95 | <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 Singh | 7affc52 | 2021-07-06 16:29:10 +0530 | [diff] [blame] | 101 | <dt>{{ $t('pageInventory.table.minPowerWatts') }}:</dt> |
Sandeepa Singh | 240c056 | 2021-05-06 21:59:20 +0530 | [diff] [blame] | 102 | <dd>{{ tableFormatter(item.minPowerWatts) }}</dd> |
| 103 | <!-- Max power --> |
Sandeepa Singh | 7affc52 | 2021-07-06 16:29:10 +0530 | [diff] [blame] | 104 | <dt>{{ $t('pageInventory.table.maxPowerWatts') }}:</dt> |
Sandeepa Singh | 240c056 | 2021-05-06 21:59:20 +0530 | [diff] [blame] | 105 | <dd>{{ tableFormatter(item.maxPowerWatts) }}</dd> |
Yoshie Muranaka | 09e8b5d | 2020-06-08 07:36:59 -0700 | [diff] [blame] | 106 | </dl> |
| 107 | </b-col> |
| 108 | </b-row> |
| 109 | </b-container> |
| 110 | </template> |
| 111 | </b-table> |
| 112 | </page-section> |
| 113 | </template> |
| 114 | |
| 115 | <script> |
| 116 | import PageSection from '@/components/Global/PageSection'; |
| 117 | import IconChevron from '@carbon/icons-vue/es/chevron--down/20'; |
Sandeepa Singh | 240c056 | 2021-05-06 21:59:20 +0530 | [diff] [blame] | 118 | import BVToastMixin from '@/components/Mixins/BVToastMixin'; |
Yoshie Muranaka | 09e8b5d | 2020-06-08 07:36:59 -0700 | [diff] [blame] | 119 | import StatusIcon from '@/components/Global/StatusIcon'; |
Dixsie Wolmers | b53e086 | 2020-09-08 14:13:38 -0500 | [diff] [blame] | 120 | |
SurenNeware | ba91c49 | 2020-10-27 14:18:54 +0530 | [diff] [blame] | 121 | import TableRowExpandMixin, { |
| 122 | expandRowLabel, |
| 123 | } from '@/components/Mixins/TableRowExpandMixin'; |
Yoshie Muranaka | 386df45 | 2020-06-18 12:45:13 -0700 | [diff] [blame] | 124 | import TableDataFormatterMixin from '@/components/Mixins/TableDataFormatterMixin'; |
Yoshie Muranaka | 09e8b5d | 2020-06-08 07:36:59 -0700 | [diff] [blame] | 125 | |
| 126 | export default { |
| 127 | components: { IconChevron, PageSection, StatusIcon }, |
Sandeepa Singh | 240c056 | 2021-05-06 21:59:20 +0530 | [diff] [blame] | 128 | mixins: [BVToastMixin, TableRowExpandMixin, TableDataFormatterMixin], |
Yoshie Muranaka | 09e8b5d | 2020-06-08 07:36:59 -0700 | [diff] [blame] | 129 | data() { |
| 130 | return { |
| 131 | fields: [ |
| 132 | { |
| 133 | key: 'expandRow', |
| 134 | label: '', |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 135 | tdClass: 'table-row-expand', |
Yoshie Muranaka | 09e8b5d | 2020-06-08 07:36:59 -0700 | [diff] [blame] | 136 | }, |
| 137 | { |
| 138 | key: 'id', |
Sandeepa Singh | 7affc52 | 2021-07-06 16:29:10 +0530 | [diff] [blame] | 139 | label: this.$t('pageInventory.table.id'), |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 140 | formatter: this.tableFormatter, |
Yoshie Muranaka | 09e8b5d | 2020-06-08 07:36:59 -0700 | [diff] [blame] | 141 | }, |
| 142 | { |
| 143 | key: 'health', |
Sandeepa Singh | 7affc52 | 2021-07-06 16:29:10 +0530 | [diff] [blame] | 144 | label: this.$t('pageInventory.table.health'), |
Dixsie Wolmers | a04d46f | 2020-10-22 06:34:56 -0500 | [diff] [blame] | 145 | formatter: this.tableFormatter, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 146 | tdClass: 'text-nowrap', |
Yoshie Muranaka | 09e8b5d | 2020-06-08 07:36:59 -0700 | [diff] [blame] | 147 | }, |
| 148 | { |
Sandeepa Singh | 240c056 | 2021-05-06 21:59:20 +0530 | [diff] [blame] | 149 | key: 'locationNumber', |
Sandeepa Singh | 7affc52 | 2021-07-06 16:29:10 +0530 | [diff] [blame] | 150 | label: this.$t('pageInventory.table.locationNumber'), |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 151 | formatter: this.tableFormatter, |
Yoshie Muranaka | 09e8b5d | 2020-06-08 07:36:59 -0700 | [diff] [blame] | 152 | }, |
| 153 | { |
Sandeepa Singh | 240c056 | 2021-05-06 21:59:20 +0530 | [diff] [blame] | 154 | key: 'identifyLed', |
Sandeepa Singh | 7affc52 | 2021-07-06 16:29:10 +0530 | [diff] [blame] | 155 | label: this.$t('pageInventory.table.identifyLed'), |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 156 | formatter: this.tableFormatter, |
| 157 | }, |
| 158 | ], |
SurenNeware | ba91c49 | 2020-10-27 14:18:54 +0530 | [diff] [blame] | 159 | expandRowLabel: expandRowLabel, |
Yoshie Muranaka | 09e8b5d | 2020-06-08 07:36:59 -0700 | [diff] [blame] | 160 | }; |
| 161 | }, |
| 162 | computed: { |
| 163 | chassis() { |
| 164 | return this.$store.getters['chassis/chassis']; |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 165 | }, |
Yoshie Muranaka | 09e8b5d | 2020-06-08 07:36:59 -0700 | [diff] [blame] | 166 | }, |
| 167 | created() { |
| 168 | this.$store.dispatch('chassis/getChassisInfo').finally(() => { |
Gunnar Mills | defc9e2 | 2020-07-07 20:29:03 -0500 | [diff] [blame] | 169 | // Emit initial data fetch complete to parent component |
Sukanya Pandey | edb8a77 | 2020-10-29 11:33:42 +0530 | [diff] [blame] | 170 | this.$root.$emit('hardware-status-chassis-complete'); |
Yoshie Muranaka | 09e8b5d | 2020-06-08 07:36:59 -0700 | [diff] [blame] | 171 | }); |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 172 | }, |
Sandeepa Singh | 240c056 | 2021-05-06 21:59:20 +0530 | [diff] [blame] | 173 | 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 Muranaka | 09e8b5d | 2020-06-08 07:36:59 -0700 | [diff] [blame] | 187 | }; |
| 188 | </script> |