From 68cbbe9014cbdcf7229a878f564d38f6d6199f25 Mon Sep 17 00:00:00 2001 From: Sandeepa Singh Date: Wed, 14 Jul 2021 16:02:22 +0530 Subject: IA update: Update control section to operations This is the third update to the information architecture changes and has the following changes: - The control section has been updated to operations - The server led page has been removed - The firmware page is moved to operations section Signed-off-by: Sandeepa Singh Change-Id: I2e23da447890d7bee51892e1f782d5f2db6dded4 --- src/store/modules/Operations/PowerControlStore.js | 60 +++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/store/modules/Operations/PowerControlStore.js (limited to 'src/store/modules/Operations/PowerControlStore.js') diff --git a/src/store/modules/Operations/PowerControlStore.js b/src/store/modules/Operations/PowerControlStore.js new file mode 100644 index 00000000..9dbddf05 --- /dev/null +++ b/src/store/modules/Operations/PowerControlStore.js @@ -0,0 +1,60 @@ +import api from '@/store/api'; +import i18n from '@/i18n'; + +const PowerControlStore = { + namespaced: true, + state: { + powerCapValue: null, + powerConsumptionValue: null, + }, + getters: { + powerCapValue: (state) => state.powerCapValue, + powerConsumptionValue: (state) => state.powerConsumptionValue, + }, + mutations: { + setPowerCapValue: (state, powerCapValue) => + (state.powerCapValue = powerCapValue), + setPowerConsumptionValue: (state, powerConsumptionValue) => + (state.powerConsumptionValue = powerConsumptionValue), + }, + actions: { + setPowerCapUpdatedValue({ commit }, value) { + commit('setPowerCapValue', value); + }, + async getPowerControl({ commit }) { + return await api + .get('/redfish/v1/Chassis/chassis/Power') + .then((response) => { + const powerControl = response.data.PowerControl; + 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('setPowerCapValue', powerCap); + commit('setPowerConsumptionValue', powerConsumption); + }) + .catch((error) => { + console.log('Power control', error); + }); + }, + async setPowerControl(_, powerCapValue) { + const data = { + PowerControl: [{ PowerLimit: { LimitInWatts: powerCapValue } }], + }; + + return await api + .patch('/redfish/v1/Chassis/chassis/Power', data) + .then(() => + i18n.t('pageServerPowerOperations.toast.successSaveSettings') + ) + .catch((error) => { + console.log(error); + throw new Error( + i18n.t('pageServerPowerOperations.toast.errorSaveSettings') + ); + }); + }, + }, +}; + +export default PowerControlStore; -- cgit v1.2.3