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 Jan 7, 2022
1 parent e14ea13 commit 7bc9635
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 24 deletions.
1 change: 0 additions & 1 deletion src/locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,6 @@
"operatingSpeedMhz": "Operating speed Mhz",
"partNumber": "Part number",
"power": "Power",
"powerInputWatts": "Power input watts",
"processorArchitecture": "Processor architecture",
"processorSummary": "Processor summary",
"processorType": "Processor type",
Expand Down
65 changes: 46 additions & 19 deletions src/store/modules/HardwareStatus/PowerSupplyStore.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import api from '@/store/api';
import i18n from '@/i18n';

const PowerSupplyStore = {
namespaced: true,
Expand All @@ -12,68 +13,94 @@ const PowerSupplyStore = {
setPowerSupply: (state, data) => {
state.powerSupplies = data.map((powerSupply) => {
const {
EfficiencyPercent,
EfficiencyRatings,
FirmwareVersion,
LocationIndicatorActive,
MemberId,
Id,
Location,
Manufacturer,
Model,
Name,
PartNumber,
PowerInputWatts,
SerialNumber,
SparePartNumber,
Location,
Status = {},
} = powerSupply;
return {
id: MemberId,
id: Id,
health: Status.Health,
partNumber: PartNumber,
serialNumber: SerialNumber,
efficiencyPercent: EfficiencyPercent,
efficiencyPercent: EfficiencyRatings[0].EfficiencyPercent,
firmwareVersion: FirmwareVersion,
identifyLed: LocationIndicatorActive,
locationNumber: Location,
manufacturer: Manufacturer,
model: Model,
powerInputWatts: PowerInputWatts,
name: Name,
sparePartNumber: SparePartNumber,
locationNumber: Location?.PartLocation?.ServiceLabel,
statusState: Status.State,
uri: powerSupply['@odata.id'],
};
});
},
},
actions: {
async getChassisCollection() {
return await api
.get('/redfish/v1/Chassis')
.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, commit }) {
async getAllPowerSupplies({ dispatch }) {
const collection = await dispatch('getChassisCollection');
if (!collection) return;
return await api
.all(collection.map((chassis) => dispatch('getChassisPower', chassis)))
.then((supplies) => {
let suppliesList = [];
supplies.forEach(
(supply) => (suppliesList = [...suppliesList, ...supply])
);
commit('setPowerSupply', suppliesList);
})
.all(collection.map((chassis) => dispatch('getPowerSupplies', chassis)))
.catch((error) => console.log(error));
},
async getChassisPower(_, id) {
async getPowerSupplies({ commit }, id) {
return await api
.get(`${id}/Power`)
.then(({ data: { PowerSupplies } }) => PowerSupplies || [])
.get(`${id}`)
.then((response) => api.get(response.data.PowerSubsystem['@odata.id']))
.then((response) => api.get(response.data.PowerSupplies['@odata.id']))
.then(({ data: { Members } }) =>
Members.map((member) => member['@odata.id'])
)
.then((powerSupplyIds) =>
api.all(powerSupplyIds.map((powerSupply) => api.get(powerSupply)))
)
.then((powerSupplies) => {
const powerSuppliesData = powerSupplies.map(
(powerSupplies) => powerSupplies.data
);
commit('setPowerSupply', powerSuppliesData);
})
.catch((error) => console.log(error));
},
async updateIdentifyLedValue(_, led) {
const uri = led.uri;
const updatedIdentifyLedValue = {
LocationIndicatorActive: led.identifyLed,
};
return await api.patch(uri, updatedIdentifyLedValue).catch((error) => {
console.log(error);
if (led.identifyLed) {
throw new Error(
i18n.t('pageHardwareStatus.toast.errorEnableIdentifyLed')
);
} else {
throw new Error(
i18n.t('pageHardwareStatus.toast.errorDisableIdentifyLed')
);
}
});
},
},
};

Expand Down
28 changes: 24 additions & 4 deletions src/views/HardwareStatus/Inventory/InventoryTablePowerSupplies.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,20 @@
{{ value }}
</template>

<!-- Toggle identify LED -->
<template #cell(identifyLed)="row">
<b-form-checkbox
v-model="row.item.identifyLed"
name="switch"
switch
@change="toggleIdentifyLedValue(row.item)"
>
<span v-if="row.item.identifyLed">
{{ $t('global.status.on') }}
</span>
<span v-else> {{ $t('global.status.off') }} </span>
</b-form-checkbox>
</template>
<template #row-details="{ item }">
<b-container fluid>
<b-row>
Expand Down Expand Up @@ -82,10 +96,7 @@
<dd>{{ dataFormatter(item.statusHealth) }}</dd>
<!-- Efficiency percent -->
<dt>{{ $t('pageInventory.table.efficiencyPercent') }}:</dt>
<dd>{{ dataFormatter(item.efficiencyPercent) }}</dd>
<!-- Power input watts -->
<dt>{{ $t('pageInventory.table.powerInputWatts') }}:</dt>
<dd>{{ dataFormatter(item.powerInputWatts) }}</dd>
<dd>{{ tableFormatter(item.efficiencyPercent) }}</dd>
</dl>
</b-col>
</b-row>
Expand Down Expand Up @@ -200,6 +211,15 @@ export default {
onFiltered(filteredItems) {
this.searchTotalFilteredRows = filteredItems.length;
},
toggleIdentifyLedValue(row) {
this.$store
.dispatch('powerSupply/updateIdentifyLedValue', {
uri: row.uri,
identifyLed: row.identifyLed,
})
.then((message) => this.successToast(message))
.catch(({ message }) => this.errorToast(message));
},
},
};
</script>

0 comments on commit 7bc9635

Please sign in to comment.