Skip to content

Commit 7d65f08

Browse files
committed
Improved performance in Sensors page
- The Sensors page takes too long to load, It is because we are trying to call the redfish endpoint: /Sensors' Members one by one and setting in the GUI. The change made is that we are using the query parameters' expand option to call only once and get all the required responses. - We are using query parameters only for those which have MaxLevels>0, else calling the APIs one by one. - Tested: Checked on a p10 system. For 306 records, it used to take 1 minute 20 seconds, now takes 7 seconds to load. Signed-off-by: Nikhil Ashoka <[email protected]> Change-Id: Ife3447e48d4f5617dcf4563ceac486e4502b2de1
1 parent 6b6926e commit 7d65f08

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

src/store/modules/HardwareStatus/SensorsStore.js

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,19 @@ const SensorsStore = {
4141
async resetSensors({ commit }) {
4242
commit('setSensorsDefault');
4343
},
44-
async getSensors({ commit }, id) {
44+
async getSensors({ dispatch }, id) {
45+
await api
46+
.get('/redfish/v1/')
47+
.then(({ data }) => {
48+
if (data?.ProtocolFeaturesSupported?.ExpandQuery?.MaxLevels > 0) {
49+
return dispatch('getSensorsUsingQueryParams', id);
50+
} else {
51+
return dispatch('getSensorsWithoutQueryParams', id);
52+
}
53+
})
54+
.catch((error) => console.log(error));
55+
},
56+
async getSensorsWithoutQueryParams({ commit }, id) {
4557
const sensors = await api
4658
.get(`${id}/Sensors`)
4759
.then((response) => response.data.Members)
@@ -72,6 +84,31 @@ const SensorsStore = {
7284
commit('setSensors', sensorData);
7385
});
7486
},
87+
async getSensorsUsingQueryParams({ commit }, id) {
88+
await api
89+
.get(`${id}/Sensors?$expand=.($levels=1)`)
90+
.then((response) => {
91+
let sensorData = [];
92+
response.data.Members.map((sensor) => {
93+
const oneSensordata = {
94+
name: sensor.Name,
95+
status: sensor.Status?.Health,
96+
currentValue: sensor.Reading,
97+
lowerCaution: sensor.Thresholds?.LowerCaution?.Reading,
98+
upperCaution: sensor.Thresholds?.UpperCaution?.Reading,
99+
lowerCritical: sensor.Thresholds?.LowerCritical?.Reading,
100+
upperCritical: sensor.Thresholds?.UpperCritical?.Reading,
101+
units: sensor.ReadingUnits,
102+
};
103+
sensorData.push(oneSensordata);
104+
commit('setSensors', sensorData);
105+
});
106+
})
107+
.then(() => {
108+
return;
109+
})
110+
.catch((error) => console.log(error));
111+
},
75112
async getThermalSensors({ commit }, id) {
76113
return await api
77114
.get(`${id}/Thermal`)

0 commit comments

Comments
 (0)