summaryrefslogtreecommitdiff
path: root/src/store/modules/ResourceManagement
diff options
context:
space:
mode:
authorMichalX Szopinski <michalx.szopinski@intel.com>2021-07-12 13:59:30 +0300
committerMaciej Magdziarz <maciejx.magdziarz@intel.com>2021-12-28 11:48:11 +0300
commitf4328edf86b284fe8836717251ce6696670dbdd5 (patch)
treea0b2688dd0defa4a079d027febbd3b08f5c5d230 /src/store/modules/ResourceManagement
parent00cb42b615602bb6563ff02f91158eb2e3b603fc (diff)
downloadwebui-vue-f4328edf86b284fe8836717251ce6696670dbdd5.tar.xz
Remove hardcoded chassis in Manage power usage
Simmilar modification to https://gerrit.openbmc-project.xyz/c/openbmc/webui-vue/+/42988 which removes the hardcoded chassis name from url on Manage power usage tab. With this modification we are displaying only informations about first power device. This change also fixes the overwriting existing power cap value on load. Signed-off-by: MichalX Szopinski <michalx.szopinski@intel.com> Change-Id: Ia164db9f2c50d98bc767c0f4729e9572a2d01da1
Diffstat (limited to 'src/store/modules/ResourceManagement')
-rw-r--r--src/store/modules/ResourceManagement/PowerControlStore.js28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/store/modules/ResourceManagement/PowerControlStore.js b/src/store/modules/ResourceManagement/PowerControlStore.js
index 9dbddf05..94c570f8 100644
--- a/src/store/modules/ResourceManagement/PowerControlStore.js
+++ b/src/store/modules/ResourceManagement/PowerControlStore.js
@@ -5,15 +5,18 @@ const PowerControlStore = {
namespaced: true,
state: {
powerCapValue: null,
+ powerCapUri: '',
powerConsumptionValue: null,
},
getters: {
powerCapValue: (state) => state.powerCapValue,
+ powerCapUri: (state) => state.powerCapUri,
powerConsumptionValue: (state) => state.powerConsumptionValue,
},
mutations: {
setPowerCapValue: (state, powerCapValue) =>
(state.powerCapValue = powerCapValue),
+ setPowerCapUri: (state, powerCapUri) => (state.powerCapUri = powerCapUri),
setPowerConsumptionValue: (state, powerConsumptionValue) =>
(state.powerConsumptionValue = powerConsumptionValue),
},
@@ -21,15 +24,29 @@ const PowerControlStore = {
setPowerCapUpdatedValue({ commit }, value) {
commit('setPowerCapValue', value);
},
- async getPowerControl({ commit }) {
+ async getChassisCollection() {
return await api
- .get('/redfish/v1/Chassis/chassis/Power')
+ .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 getPowerControl({ dispatch, commit }) {
+ const collection = await dispatch('getChassisCollection');
+ if (!collection || collection.length === 0) return;
+ return await api
+ .get(`${collection[0]}`)
+ .then((response) => api.get(response.data.Power['@odata.id']))
.then((response) => {
const powerControl = response.data.PowerControl;
+ if (!powerControl || powerControl.length === 0) return;
+ const powerCapUri = powerControl[0]['@odata.id'];
const powerCap = powerControl[0].PowerLimit.LimitInWatts;
// If system is powered off, power consumption does not exist in the PowerControl
const powerConsumption = powerControl[0].PowerConsumedWatts || null;
-
+ commit('setPowerCapUri', powerCapUri);
commit('setPowerCapValue', powerCap);
commit('setPowerConsumptionValue', powerConsumption);
})
@@ -37,13 +54,12 @@ const PowerControlStore = {
console.log('Power control', error);
});
},
- async setPowerControl(_, powerCapValue) {
+ async setPowerControl({ state }, powerCapValue) {
const data = {
PowerControl: [{ PowerLimit: { LimitInWatts: powerCapValue } }],
};
-
return await api
- .patch('/redfish/v1/Chassis/chassis/Power', data)
+ .patch(state.powerCapUri, data)
.then(() =>
i18n.t('pageServerPowerOperations.toast.successSaveSettings')
)