From 7ee53240fb2d5e89d13bb68e13723fe6e4e83458 Mon Sep 17 00:00:00 2001 From: Yong Li Date: Wed, 14 Oct 2020 13:06:48 +0800 Subject: Catch the TypeError in sensors page On the sensors page, there is the below error and some sensors are missing: Uncaught (in promise) TypeError: Cannot read property 'LowerCaution' of undefined The root cause is that some sensors do not support all these Thresholds properties, add the checking to catch such errors. Tested: These sensors in redfish/v1/Chassis/$id/Sensors/ can be displayed in sensors web page Signed-off-by: Yong Li Change-Id: Ic80048045ee8e293e693811c246723557489fb35 --- src/store/modules/Health/SensorsStore.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/store/modules/Health/SensorsStore.js b/src/store/modules/Health/SensorsStore.js index 24ad2d1e..edcbf7b2 100644 --- a/src/store/modules/Health/SensorsStore.js +++ b/src/store/modules/Health/SensorsStore.js @@ -53,10 +53,10 @@ const SensorsStore = { name: data.Name, status: data.Status.Health, currentValue: data.Reading, - lowerCaution: data.Thresholds.LowerCaution.Reading, - upperCaution: data.Thresholds.UpperCaution.Reading, - lowerCritical: data.Thresholds.LowerCritical.Reading, - upperCritical: data.Thresholds.UpperCritical.Reading, + lowerCaution: data.Thresholds?.LowerCaution?.Reading, + upperCaution: data.Thresholds?.UpperCaution?.Reading, + lowerCritical: data.Thresholds?.LowerCritical?.Reading, + upperCritical: data.Thresholds?.UpperCritical?.Reading, units: data.ReadingUnits }; }); -- cgit v1.2.3