diff options
author | Sivaprabu Ganesan <sivaprabug@ami.com> | 2023-07-25 12:42:46 +0300 |
---|---|---|
committer | Gunnar Mills <gmills@us.ibm.com> | 2023-08-08 00:12:27 +0300 |
commit | 582ac0d472a865294f496ff24f7a49af90bfabfe (patch) | |
tree | c6157f91e873e9c7235212b2d6e0b53b0c364c7c /src/store | |
parent | 43e3bd26133b06ed117a3a3f10b2bc09e2c2aafc (diff) | |
download | webui-vue-582ac0d472a865294f496ff24f7a49af90bfabfe.tar.xz |
Fan data from Thermal or ThermalSubsystem API
Fan data API switch in Inventory and LEDs page based on
environment variable VUE_APP_FAN_DATA_FROM_THERMAL_SUBSYSTEM.
Backend Support PR:
https://gerrit.openbmc.org/c/openbmc/bmcweb/+/57533
Change-Id: I95ac9f9cef97bdab84a179b3e318eb37ab11752b
Signed-off-by: Sivaprabu Ganesan <sivaprabug@ami.com>
Diffstat (limited to 'src/store')
-rw-r--r-- | src/store/modules/HardwareStatus/FanStore.js | 99 |
1 files changed, 72 insertions, 27 deletions
diff --git a/src/store/modules/HardwareStatus/FanStore.js b/src/store/modules/HardwareStatus/FanStore.js index 3f172d2d..832ef634 100644 --- a/src/store/modules/HardwareStatus/FanStore.js +++ b/src/store/modules/HardwareStatus/FanStore.js @@ -11,29 +11,49 @@ const FanStore = { mutations: { setFanInfo: (state, data) => { state.fans = data.map((fan) => { - const { - IndicatorLED, - Location, - MemberId, - Name, - Reading, - ReadingUnits, - Status = {}, - PartNumber, - SerialNumber, - } = fan; - return { - id: MemberId, - health: Status.Health, - partNumber: PartNumber, - serialNumber: SerialNumber, - healthRollup: Status.HealthRollup, - identifyLed: IndicatorLED, - locationNumber: Location, - name: Name, - speed: Reading + ' ' + ReadingUnits, - statusState: Status.State, - }; + const ThermalSubsystem = + process.env.VUE_APP_FAN_DATA_FROM_THERMAL_SUBSYSTEM === 'true' + ? true + : false; + if (ThermalSubsystem) { + const { + Id, + Name, + PartNumber, + SerialNumber, + SpeedPercent = {}, + Status = {}, + } = fan; + return { + id: Id, + health: Status.Health, + name: Name, + speed: SpeedPercent.Reading, + statusState: Status.State, + healthRollup: Status.HealthRollup, + partNumber: PartNumber, + serialNumber: SerialNumber, + }; + } else { + const { + MemberId, + Name, + Reading, + Status = {}, + PartNumber, + SerialNumber, + } = fan; + return { + id: MemberId, + health: Status.Health, + partNumber: PartNumber, + serialNumber: SerialNumber, + healthRollup: Status.HealthRollup, + name: Name, + speed: Reading, + statusState: Status.State, + }; + } }); }, }, @@ -59,10 +79,35 @@ const FanStore = { .catch((error) => console.log(error)); }, async getChassisFans(_, chassis) { - return await api - .get(chassis.Thermal['@odata.id']) - .then(({ data: { Fans } }) => Fans || []) - .catch((error) => console.log(error)); + const ThermalSubsystem = + process.env.VUE_APP_FAN_DATA_FROM_THERMAL_SUBSYSTEM === 'true' + ? true + : false; + if (ThermalSubsystem) { + return await api + .get(chassis.ThermalSubsystem['@odata.id']) + .then((response) => { + return api.get(`${response.data.Fans['@odata.id']}`); + }) + .then(({ data: { Members } }) => { + const promises = Members.map((member) => + api.get(member['@odata.id']) + ); + return api.all(promises); + }) + .then((response) => { + const data = response.map(({ data }) => data); + return data; + }) + .catch((error) => console.log(error)); + } else { + return await api + .get(chassis.Thermal['@odata.id']) + .then(({ data: { Fans } }) => { + return Fans || []; + }) + .catch((error) => console.log(error)); + } }, }, }; |