From d7a378c23f71cbd2532aaa2b5b1f85e20b3ce80f Mon Sep 17 00:00:00 2001 From: Dixsie Wolmers Date: Fri, 20 Aug 2021 08:17:57 -0500 Subject: [PATCH] Update power supply table to use PowerSubsystem schema (#6) - 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 -
will be removed in separate commit Signed-off-by: Dixsie Wolmers --- src/locales/en-US.json | 1 - .../HardwareStatus/PowerSupplyStore.js | 65 +++++++++++++------ .../Inventory/InventoryTablePowerSupplies.vue | 28 ++++++-- 3 files changed, 70 insertions(+), 24 deletions(-) diff --git a/src/locales/en-US.json b/src/locales/en-US.json index 166c3f93c3..e1f446272d 100644 --- a/src/locales/en-US.json +++ b/src/locales/en-US.json @@ -413,7 +413,6 @@ "name": "Name", "partNumber": "Part number", "power": "Power", - "powerInputWatts": "Power input watts", "processorArchitecture": "Processor architecture", "processorSummary": "Processor summary", "processorType": "Processor type", diff --git a/src/store/modules/HardwareStatus/PowerSupplyStore.js b/src/store/modules/HardwareStatus/PowerSupplyStore.js index dc7691da31..8ce93974b3 100644 --- a/src/store/modules/HardwareStatus/PowerSupplyStore.js +++ b/src/store/modules/HardwareStatus/PowerSupplyStore.js @@ -1,4 +1,5 @@ import api from '@/store/api'; +import i18n from '@/i18n'; const PowerSupplyStore = { namespaced: true, @@ -12,35 +13,36 @@ 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'], }; }); }, @@ -48,32 +50,57 @@ const PowerSupplyStore = { 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') + ); + } + }); + }, }, }; diff --git a/src/views/HardwareStatus/Inventory/InventoryTablePowerSupplies.vue b/src/views/HardwareStatus/Inventory/InventoryTablePowerSupplies.vue index ba0896bf4d..8de81349a2 100644 --- a/src/views/HardwareStatus/Inventory/InventoryTablePowerSupplies.vue +++ b/src/views/HardwareStatus/Inventory/InventoryTablePowerSupplies.vue @@ -50,6 +50,20 @@ {{ value }} + +