From b440616c23b61166ae6d87839a70eec31bdca235 Mon Sep 17 00:00:00 2001 From: Sandeepa Singh Date: Mon, 26 Jul 2021 15:05:39 +0530 Subject: IA update: Update access and control section This is the fifth commit of the information architecture changes and has the following changes: - The icon for access and control has been updated - Access and control section has been updated to security and access section - Security settings page has been updated to policies page and moved to security and access section - Client sessions page has been updated to sessions page - Local user management page has been updated to user management page - SSL certificates page has been updated to certificates page Signed-off-by: Sandeepa Singh Change-Id: Ie93cee9002742ecf7d33615636f4f159f4395fc4 --- .../modules/SecurityAndAccess/PoliciesStore.js | 87 ++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 src/store/modules/SecurityAndAccess/PoliciesStore.js (limited to 'src/store/modules/SecurityAndAccess/PoliciesStore.js') diff --git a/src/store/modules/SecurityAndAccess/PoliciesStore.js b/src/store/modules/SecurityAndAccess/PoliciesStore.js new file mode 100644 index 00000000..1e195527 --- /dev/null +++ b/src/store/modules/SecurityAndAccess/PoliciesStore.js @@ -0,0 +1,87 @@ +import api from '@/store/api'; +import i18n from '@/i18n'; + +const PoliciesStore = { + namespaced: true, + state: { + sshProtocolEnabled: false, + ipmiProtocolEnabled: false, + }, + getters: { + sshProtocolEnabled: (state) => state.sshProtocolEnabled, + ipmiProtocolEnabled: (state) => state.ipmiProtocolEnabled, + }, + mutations: { + setSshProtocolEnabled: (state, sshProtocolEnabled) => + (state.sshProtocolEnabled = sshProtocolEnabled), + setIpmiProtocolEnabled: (state, ipmiProtocolEnabled) => + (state.ipmiProtocolEnabled = ipmiProtocolEnabled), + }, + actions: { + async getNetworkProtocolStatus({ commit }) { + return await api + .get('/redfish/v1/Managers/bmc/NetworkProtocol') + .then((response) => { + const sshProtocol = response.data.SSH.ProtocolEnabled; + const ipmiProtocol = response.data.IPMI.ProtocolEnabled; + commit('setSshProtocolEnabled', sshProtocol); + commit('setIpmiProtocolEnabled', ipmiProtocol); + }) + .catch((error) => console.log(error)); + }, + async saveIpmiProtocolState({ commit }, protocolEnabled) { + commit('setIpmiProtocolEnabled', protocolEnabled); + const ipmi = { + IPMI: { + ProtocolEnabled: protocolEnabled, + }, + }; + return await api + .patch('/redfish/v1/Managers/bmc/NetworkProtocol', ipmi) + .then(() => { + if (protocolEnabled) { + return i18n.t('pagePolicies.toast.successIpmiEnabled'); + } else { + return i18n.t('pagePolicies.toast.successIpmiDisabled'); + } + }) + .catch((error) => { + console.log(error); + commit('setIpmiProtocolEnabled', !protocolEnabled); + if (protocolEnabled) { + throw new Error(i18n.t('pagePolicies.toast.errorIpmiEnabled')); + } else { + throw new Error(i18n.t('pagePolicies.toast.errorIpmiDisabled')); + } + }); + }, + async saveSshProtocolState({ commit }, protocolEnabled) { + commit('setSshProtocolEnabled', protocolEnabled); + const ssh = { + SSH: { + ProtocolEnabled: protocolEnabled, + }, + }; + return await api + .patch('/redfish/v1/Managers/bmc/NetworkProtocol', ssh) + .then(() => { + if (protocolEnabled) { + return i18n.t('pagePolicies.toast.successSshEnabled'); + } else { + return i18n.t('pagePolicies.toast.successSshDisabled'); + } + }) + .catch((error) => { + console.log(error); + commit('setSshProtocolEnabled', !protocolEnabled); + if (protocolEnabled) { + throw new Error(i18n.t('pagePolicies.toast.errorSshEnabled')); + } else { + throw new Error(i18n.t('pagePolicies.toast.errorSshDisabled')); + } + }); + }, + }, +}; + +export default PoliciesStore; -- cgit v1.2.3