diff --git a/src/locales/en-US.json b/src/locales/en-US.json index 9756b5145b..15c129be89 100644 --- a/src/locales/en-US.json +++ b/src/locales/en-US.json @@ -428,6 +428,7 @@ "serviceEnabled": "Service enabled", "serviceEntryPointUuid": "Service entry point UUID", "sparePartNumber": "Spare part number", + "speedPercent": "Speed percent", "statusHealthRollup": "Status (Health rollup)", "statusState": "Status (State)", "subModel": "Sub model", diff --git a/src/store/modules/HardwareStatus/FanStore.js b/src/store/modules/HardwareStatus/FanStore.js index fca1f32680..d8a68c4ff5 100644 --- a/src/store/modules/HardwareStatus/FanStore.js +++ b/src/store/modules/HardwareStatus/FanStore.js @@ -1,4 +1,5 @@ import api from '@/store/api'; +import i18n from '@/i18n'; const FanStore = { namespaced: true, @@ -12,38 +13,83 @@ const FanStore = { setFanInfo: (state, data) => { state.fans = data.map((fan) => { const { - IndicatorLED, + LocationIndicatorActive, Location, - MemberId, + Id, Name, - Reading, - ReadingUnits, + SpeedPercent, Status = {}, PartNumber, SerialNumber, } = fan; return { - id: MemberId, + id: Id, health: Status.Health, partNumber: PartNumber, serialNumber: SerialNumber, healthRollup: Status.HealthRollup, - identifyLed: IndicatorLED, + identifyLed: LocationIndicatorActive, locationNumber: Location, name: Name, - speed: Reading + ' ' + ReadingUnits, + speedPercent: SpeedPercent.Reading, statusState: Status.State, + uri: fan['@odata.id'], }; }); }, }, actions: { - async getFanInfo({ commit }) { + async getChassisCollection() { return await api - .get('/redfish/v1/Chassis/chassis/Thermal') - .then(({ data: { Fans = [] } }) => commit('setFanInfo', Fans)) + .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 getAllFans({ dispatch }) { + const collection = await dispatch('getChassisCollection'); + if (!collection) return; + return await api + .all(collection.map((chassis) => dispatch('getFanData', chassis))) + .catch((error) => console.log(error)); + }, + async getFanData({ commit }, id) { + return await api + .get(`${id}`) + .then((response) => + api.get(response.data.ThermalSubsystem['@odata.id']) + ) + .then((response) => api.get(response.data.Fans['@odata.id'])) + .then(({ data: { Members } }) => + Members.map((member) => member['@odata.id']) + ) + .then((fanIds) => api.all(fanIds.map((fan) => api.get(fan)))) + .then((fans) => { + const fansData = fans.map((fans) => fans.data); + commit('setFanInfo', fansData); + }) + .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/InventoryTableFans.vue b/src/views/HardwareStatus/Inventory/InventoryTableFans.vue index ff568043dd..b412f1676e 100644 --- a/src/views/HardwareStatus/Inventory/InventoryTableFans.vue +++ b/src/views/HardwareStatus/Inventory/InventoryTableFans.vue @@ -34,7 +34,7 @@