From 14914269eff5f06571f8dab9a1d4bf8e8509c4dc Mon Sep 17 00:00:00 2001 From: Nikhil Ashoka Date: Mon, 30 Sep 2024 20:38:43 +0530 Subject: Updated Power restore policy URI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Previously, we used to get the values for power restore policy page from“JsonSchemas/ComputerSystem/ComputerSystem.json”. Now we have removed the hardcoded API call and are fetching the values from the JsonSchemas/ComputerSystem’s URI because we would have versioned ComputerSystem.json in the redfish response. Change-Id: I1a25cbbb3dfc536485a6f71a359ae32c6eadf5f7 Signed-off-by: Nikhil Ashoka Signed-off-by: Surya Venkatesan --- src/store/modules/Settings/PowerPolicyStore.js | 47 +++++++++++++++----------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/src/store/modules/Settings/PowerPolicyStore.js b/src/store/modules/Settings/PowerPolicyStore.js index 9ee12390..9cbf3c8b 100644 --- a/src/store/modules/Settings/PowerPolicyStore.js +++ b/src/store/modules/Settings/PowerPolicyStore.js @@ -20,27 +20,36 @@ const PowerPolicyStore = { actions: { async getPowerRestorePolicies({ commit }) { return await api - .get('/redfish/v1/JsonSchemas/ComputerSystem/ComputerSystem.json') - .then( - ({ - data: { - definitions: { PowerRestorePolicyTypes = {} }, - }, - }) => { - let powerPoliciesData = PowerRestorePolicyTypes.enum.map( - (powerState) => { - let desc = `${i18n.global.t( - `pagePowerRestorePolicy.policies.${powerState}`, - )} - ${PowerRestorePolicyTypes.enumDescriptions[powerState]}`; - return { - state: powerState, - desc, - }; + .get('/redfish/v1/JsonSchemas/ComputerSystem') + .then(async (response) => { + if ( + response.data?.Location.length > 0 && + response.data?.Location[0].Uri + ) { + return await api.get(response.data?.Location[0].Uri).then( + ({ + data: { + definitions: { PowerRestorePolicyTypes = {} }, + }, + }) => { + let powerPoliciesData = PowerRestorePolicyTypes.enum.map( + (powerState) => { + let desc = `${i18n.global.t( + `pagePowerRestorePolicy.policies.${powerState}`, + )} - ${ + PowerRestorePolicyTypes.enumDescriptions[powerState] + }`; + return { + state: powerState, + desc, + }; + }, + ); + commit('setPowerRestorePolicies', powerPoliciesData); }, ); - commit('setPowerRestorePolicies', powerPoliciesData); - }, - ); + } + }); }, async getPowerRestoreCurrentPolicy({ commit }) { return await api -- cgit v1.2.3