Skip to content

Commit

Permalink
Update power supply table to use PowerSubsystem schema (#6)
Browse files Browse the repository at this point in the history
- Adds toggle switch in identify LED column to enable/disable
the LED
- Updates efficiencyPercent in store per pending schema
changes
- Removes power input watts
- Adds section divider
- <br />  will be removed in separate commit

Signed-off-by: Dixsie Wolmers <[email protected]>
  • Loading branch information
dixsie authored and rfrandse committed Jun 30, 2022
1 parent 3a6b906 commit 854160c
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 72 deletions.
32 changes: 5 additions & 27 deletions src/store/modules/HardwareStatus/PowerSupplyStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ const PowerSupplyStore = {
setPowerSupply: (state, data) => {
state.powerSupplies = data.map((powerSupply) => {
const {
EfficiencyRatings,
FirmwareVersion,
Location,
LocationIndicatorActive,
Id,
Location,
Manufacturer,
Model,
Name,
PartNumber,
Expand All @@ -31,11 +29,9 @@ const PowerSupplyStore = {
health: Status.Health,
partNumber: PartNumber,
serialNumber: SerialNumber,
efficiencyPercent: EfficiencyRatings[0].EfficiencyPercent,
firmwareVersion: FirmwareVersion,
identifyLed: LocationIndicatorActive,
locationNumber: Location?.PartLocation?.ServiceLabel,
manufacturer: Manufacturer,
model: Model,
name: Name,
sparePartNumber: SparePartNumber,
Expand All @@ -46,25 +42,9 @@ const PowerSupplyStore = {
},
},
actions: {
async getChassisCollection() {
async getAllPowerSupplies({ commit }, requestBody) {
return await api
.get('/redfish/v1/')
.then((response) => api.get(response.data.Chassis['@odata.id']))
.then(({ data: { Members } }) =>
Members.map((member) => member['@odata.id'])
)
.catch((error) => console.log(error));
},
async getAllPowerSupplies({ dispatch }) {
const collection = await dispatch('getChassisCollection');
if (!collection) return;
return await api
.all(collection.map((chassis) => dispatch('getPowerSupplies', chassis)))
.catch((error) => console.log(error));
},
async getPowerSupplies({ commit }, id) {
return await api
.get(`${id}`)
.get(`${requestBody.uri}`)
.then((response) => api.get(response.data.PowerSubsystem['@odata.id']))
.then((response) => api.get(response.data.PowerSupplies['@odata.id']))
.then(({ data: { Members } }) =>
Expand All @@ -89,12 +69,10 @@ const PowerSupplyStore = {
return await api.patch(uri, updatedIdentifyLedValue).catch((error) => {
console.log(error);
if (led.identifyLed) {
throw new Error(
i18n.t('pageHardwareStatus.toast.errorEnableIdentifyLed')
);
throw new Error(i18n.t('pageInventory.toast.errorEnableIdentifyLed'));
} else {
throw new Error(
i18n.t('pageHardwareStatus.toast.errorDisableIdentifyLed')
i18n.t('pageInventory.toast.errorDisableIdentifyLed')
);
}
});
Expand Down
111 changes: 66 additions & 45 deletions src/views/HardwareStatus/Inventory/InventoryTablePowerSupplies.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
no-sort-reset
hover
responsive="md"
sort-by="health"
sort-by="id"
show-empty
:items="powerSupplies"
:fields="fields"
:sort-desc="true"
:sort-desc="false"
:sort-compare="sortCompare"
:filter="searchFilter"
:empty-text="$t('global.table.emptyMessage')"
Expand All @@ -50,12 +50,20 @@
<status-icon :status="statusIcon(value)" />
{{ value }}
</template>

<!-- Status -->
<template #cell(status)="row">
{{
row.item.statusState === 'Enabled'
? $t('global.status.present')
: $t('global.status.absent')
}}
</template>
<!-- Toggle identify LED -->
<template #cell(identifyLed)="row">
<b-form-checkbox
v-model="row.item.identifyLed"
name="switch"
:disabled="serverStatus"
switch
@change="toggleIdentifyLedValue(row.item)"
>
Expand All @@ -68,52 +76,29 @@
<template #row-details="{ item }">
<b-container fluid>
<b-row>
<b-col sm="6" xl="4">
<b-col sm="6" xl="6">
<dl>
<!-- Name -->
<dt>{{ $t('pageInventory.table.name') }}:</dt>
<dt>{{ $t('pageInventory.table.name') }}</dt>
<dd>{{ dataFormatter(item.name) }}</dd>
<!-- Part number -->
<dt>{{ $t('pageInventory.table.partNumber') }}:</dt>
<dt>{{ $t('pageInventory.table.partNumber') }}</dt>
<dd>{{ dataFormatter(item.partNumber) }}</dd>
<!-- Serial number -->
<dt>{{ $t('pageInventory.table.serialNumber') }}:</dt>
<dt>{{ $t('pageInventory.table.serialNumber') }}</dt>
<dd>{{ dataFormatter(item.serialNumber) }}</dd>
</dl>
</b-col>
<b-col sm="6" xl="6">
<dl>
<!-- Spare part number -->
<dt>{{ $t('pageInventory.table.sparePartNumber') }}:</dt>
<dt>{{ $t('pageInventory.table.sparePartNumber') }}</dt>
<dd>{{ dataFormatter(item.sparePartNumber) }}</dd>
<!-- Model -->
<dt>{{ $t('pageInventory.table.model') }}:</dt>
<dt>{{ $t('pageInventory.table.bmcManagerModel') }}</dt>
<dd>{{ dataFormatter(item.model) }}</dd>
</dl>
</b-col>
<b-col sm="6" xl="4">
<dl>
<!-- Status state -->
<dt>{{ $t('pageInventory.table.statusState') }}:</dt>
<dd>{{ dataFormatter(item.statusState) }}</dd>
<!-- Status Health rollup state -->
<dt>{{ $t('pageInventory.table.statusHealthRollup') }}:</dt>
<dd>{{ dataFormatter(item.statusHealth) }}</dd>
<!-- Efficiency percent -->
<dt>{{ $t('pageInventory.table.efficiencyPercent') }}:</dt>
<dd>{{ dataFormatter(item.efficiencyPercent) }}</dd>
</dl>
</b-col>
</b-row>
<div class="section-divider mb-3 mt-3"></div>
<b-row>
<b-col sm="6" xl="4">
<dl>
<!-- Manufacturer -->
<dt>{{ $t('pageInventory.table.manufacturer') }}:</dt>
<dd>{{ dataFormatter(item.manufacturer) }}</dd>
</dl>
</b-col>
<b-col sm="6" xl="4">
<dl>
<!-- Firmware version -->
<dt>{{ $t('pageInventory.table.firmwareVersion') }}:</dt>
<dt>{{ $t('pageInventory.table.firmwareVersion') }}</dt>
<dd>{{ dataFormatter(item.firmwareVersion) }}</dd>
</dl>
</b-col>
Expand All @@ -139,15 +124,23 @@ import SearchFilterMixin, {
import TableRowExpandMixin, {
expandRowLabel,
} from '@/components/Mixins/TableRowExpandMixin';
import BVToastMixin from '@/components/Mixins/BVToastMixin';
export default {
components: { IconChevron, PageSection, StatusIcon, Search, TableCellCount },
mixins: [
BVToastMixin,
TableRowExpandMixin,
DataFormatterMixin,
TableSortMixin,
SearchFilterMixin,
],
props: {
chassis: {
type: String,
default: '',
},
},
data() {
return {
isBusy: true,
Expand All @@ -159,8 +152,8 @@ export default {
sortable: false,
},
{
key: 'id',
label: this.$t('pageInventory.table.id'),
key: 'name',
label: this.$t('pageInventory.table.name'),
formatter: this.dataFormatter,
sortable: true,
},
Expand All @@ -171,6 +164,13 @@ export default {
sortable: true,
tdClass: 'text-nowrap',
},
{
key: 'status',
label: this.$t('pageUserManagement.table.status'),
formatter: this.dataFormatter,
sortable: true,
tdClass: 'text-nowrap',
},
{
key: 'locationNumber',
label: this.$t('pageInventory.table.locationNumber'),
Expand All @@ -197,13 +197,35 @@ export default {
powerSupplies() {
return this.$store.getters['powerSupply/powerSupplies'];
},
serverStatus() {
if (this.chassis.endsWith('chassis')) {
return false;
} else if (this.$store.getters['global/serverStatus'] !== 'on') {
return true;
} else {
return false;
}
},
},
watch: {
chassis: function (value) {
this.$store
.dispatch('powerSupply/getAllPowerSupplies', { uri: value })
.finally(() => {
// Emit initial data fetch complete to parent component
this.$root.$emit('hardware-status-power-supplies-complete');
this.isBusy = false;
});
},
},
created() {
this.$store.dispatch('powerSupply/getAllPowerSupplies').finally(() => {
// Emit initial data fetch complete to parent component
this.$root.$emit('hardware-status-power-supplies-complete');
this.isBusy = false;
});
this.$store
.dispatch('powerSupply/getAllPowerSupplies', { uri: this.chassis })
.finally(() => {
// Emit initial data fetch complete to parent component
this.$root.$emit('hardware-status-power-supplies-complete');
this.isBusy = false;
});
},
methods: {
sortCompare(a, b, key) {
Expand All @@ -220,7 +242,6 @@ export default {
uri: row.uri,
identifyLed: row.identifyLed,
})
.then((message) => this.successToast(message))
.catch(({ message }) => this.errorToast(message));
},
},
Expand Down

0 comments on commit 854160c

Please sign in to comment.