diff options
author | Sandeepa Singh <sandeepa.singh@ibm.com> | 2021-07-14 13:32:22 +0300 |
---|---|---|
committer | Derick Montague <derick.montague@ibm.com> | 2021-08-10 22:20:42 +0300 |
commit | 68cbbe9014cbdcf7229a878f564d38f6d6199f25 (patch) | |
tree | cd7138959f405cb44b5d62000da9d364ed238b91 /src/store/modules/Control/BootSettingsStore.js | |
parent | 7affc529b7fba41193c4d48764707e9961cdd22d (diff) | |
download | webui-vue-68cbbe9014cbdcf7229a878f564d38f6d6199f25.tar.xz |
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 <sandeepa.singh@ibm.com>
Change-Id: I2e23da447890d7bee51892e1f782d5f2db6dded4
Diffstat (limited to 'src/store/modules/Control/BootSettingsStore.js')
-rw-r--r-- | src/store/modules/Control/BootSettingsStore.js | 136 |
1 files changed, 0 insertions, 136 deletions
diff --git a/src/store/modules/Control/BootSettingsStore.js b/src/store/modules/Control/BootSettingsStore.js deleted file mode 100644 index 7a36dd84..00000000 --- a/src/store/modules/Control/BootSettingsStore.js +++ /dev/null @@ -1,136 +0,0 @@ -import api from '@/store/api'; -import i18n from '@/i18n'; - -const BootSettingsStore = { - namespaced: true, - state: { - bootSourceOptions: [], - bootSource: null, - overrideEnabled: null, - tpmEnabled: null, - }, - getters: { - bootSourceOptions: (state) => state.bootSourceOptions, - bootSource: (state) => state.bootSource, - overrideEnabled: (state) => state.overrideEnabled, - tpmEnabled: (state) => state.tpmEnabled, - }, - mutations: { - setBootSourceOptions: (state, bootSourceOptions) => - (state.bootSourceOptions = bootSourceOptions), - setBootSource: (state, bootSource) => (state.bootSource = bootSource), - setOverrideEnabled: (state, overrideEnabled) => { - if (overrideEnabled === 'Once') { - state.overrideEnabled = true; - } else { - // 'Continuous' or 'Disabled' - state.overrideEnabled = false; - } - }, - setTpmPolicy: (state, tpmEnabled) => (state.tpmEnabled = tpmEnabled), - }, - actions: { - async getBootSettings({ commit }) { - return await api - .get('/redfish/v1/Systems/system') - .then(({ data: { Boot } }) => { - commit( - 'setBootSourceOptions', - Boot['BootSourceOverrideTarget@Redfish.AllowableValues'] - ); - commit('setOverrideEnabled', Boot.BootSourceOverrideEnabled); - commit('setBootSource', Boot.BootSourceOverrideTarget); - }) - .catch((error) => console.log(error)); - }, - saveBootSettings({ commit, dispatch }, { bootSource, overrideEnabled }) { - const data = { Boot: {} }; - data.Boot.BootSourceOverrideTarget = bootSource; - - if (overrideEnabled) { - data.Boot.BootSourceOverrideEnabled = 'Once'; - } else if (bootSource === 'None') { - data.Boot.BootSourceOverrideEnabled = 'Disabled'; - } else { - data.Boot.BootSourceOverrideEnabled = 'Continuous'; - } - - return api - .patch('/redfish/v1/Systems/system', data) - .then((response) => { - // If request success, commit the values - commit('setBootSource', data.Boot.BootSourceOverrideTarget); - commit('setOverrideEnabled', data.Boot.BootSourceOverrideEnabled); - return response; - }) - .catch((error) => { - console.log(error); - // If request error, GET saved options - dispatch('getBootSettings'); - return error; - }); - }, - async getTpmPolicy({ commit }) { - // TODO: switch to Redfish when available - return await api - .get('/xyz/openbmc_project/control/host0/TPMEnable') - .then(({ data: { data: { TPMEnable } } }) => - commit('setTpmPolicy', TPMEnable) - ) - .catch((error) => console.log(error)); - }, - saveTpmPolicy({ commit, dispatch }, tpmEnabled) { - // TODO: switch to Redfish when available - const data = { data: tpmEnabled }; - return api - .put( - '/xyz/openbmc_project/control/host0/TPMEnable/attr/TPMEnable', - data - ) - .then((response) => { - // If request success, commit the values - commit('setTpmPolicy', tpmEnabled); - return response; - }) - .catch((error) => { - console.log(error); - // If request error, GET saved policy - dispatch('getTpmPolicy'); - return error; - }); - }, - async saveSettings( - { dispatch }, - { bootSource, overrideEnabled, tpmEnabled } - ) { - const promises = []; - - if (bootSource !== null || overrideEnabled !== null) { - promises.push( - dispatch('saveBootSettings', { bootSource, overrideEnabled }) - ); - } - if (tpmEnabled !== null) { - promises.push(dispatch('saveTpmPolicy', tpmEnabled)); - } - - return await api.all(promises).then( - api.spread((...responses) => { - let message = i18n.t( - 'pageServerPowerOperations.toast.successSaveSettings' - ); - responses.forEach((response) => { - if (response instanceof Error) { - throw new Error( - i18n.t('pageServerPowerOperations.toast.errorSaveSettings') - ); - } - }); - return message; - }) - ); - }, - }, -}; - -export default BootSettingsStore; |