diff options
author | Sandeepa Singh <sandeepa.singh@ibm.com> | 2021-07-19 15:34:18 +0300 |
---|---|---|
committer | Derick Montague <derick.montague@ibm.com> | 2021-08-10 22:20:42 +0300 |
commit | f67f769f2304bca64d2b9758e22c21203960eef9 (patch) | |
tree | 167d6ac96a90b098887f9cf1dc4e96a895e2754c /src/store/modules/Settings/PowerPolicyStore.js | |
parent | 68cbbe9014cbdcf7229a878f564d38f6d6199f25 (diff) | |
download | webui-vue-f67f769f2304bca64d2b9758e22c21203960eef9.tar.xz |
IA update: Update configuration to settings
This is the fourth update to information architecture changes and has
the following changes:
- The configuration section is updated to settings
- The date and time settings page is updated to date and time
- The network settings page is updated to network
- The power restore policy page in operations section is moved to
settings section
Signed-off-by: Sandeepa Singh <sandeepa.singh@ibm.com>
Change-Id: I6f5ab25f5227530be430bd39a4d9629b3bf09d8b
Diffstat (limited to 'src/store/modules/Settings/PowerPolicyStore.js')
-rw-r--r-- | src/store/modules/Settings/PowerPolicyStore.js | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/store/modules/Settings/PowerPolicyStore.js b/src/store/modules/Settings/PowerPolicyStore.js new file mode 100644 index 00000000..4e76cdfe --- /dev/null +++ b/src/store/modules/Settings/PowerPolicyStore.js @@ -0,0 +1,72 @@ +import api from '@/store/api'; +import i18n from '@/i18n'; + +const PowerControlStore = { + namespaced: true, + state: { + powerRestoreCurrentPolicy: null, + powerRestorePolicies: [], + }, + getters: { + powerRestoreCurrentPolicy: (state) => state.powerRestoreCurrentPolicy, + powerRestorePolicies: (state) => state.powerRestorePolicies, + }, + mutations: { + setPowerRestoreCurrentPolicy: (state, powerRestoreCurrentPolicy) => + (state.powerRestoreCurrentPolicy = powerRestoreCurrentPolicy), + setPowerRestorePolicies: (state, powerRestorePolicies) => + (state.powerRestorePolicies = powerRestorePolicies), + }, + 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.t( + `pagePowerRestorePolicy.policies.${powerState}` + )} - ${PowerRestorePolicyTypes.enumDescriptions[powerState]}`; + return { + state: powerState, + desc, + }; + } + ); + commit('setPowerRestorePolicies', powerPoliciesData); + } + ); + }, + async getPowerRestoreCurrentPolicy({ commit }) { + api + .get('/redfish/v1/Systems/system') + .then(({ data: { PowerRestorePolicy } }) => { + commit('setPowerRestoreCurrentPolicy', PowerRestorePolicy); + }) + .catch((error) => console.log(error)); + }, + async setPowerRestorePolicy({ commit }, powerPolicy) { + const data = { PowerRestorePolicy: powerPolicy }; + + return await api + .patch('/redfish/v1/Systems/system', data) + .then(() => + commit('setPowerRestoreCurrentPolicy', data.PowerRestorePolicy) + ) + .then(() => i18n.t('pagePowerRestorePolicy.toast.successSaveSettings')) + .catch((error) => { + console.log(error); + throw new Error( + i18n.t('pagePowerRestorePolicy.toast.errorSaveSettings') + ); + }); + }, + }, +}; + +export default PowerControlStore; |