summaryrefslogtreecommitdiff
path: root/src/store
diff options
context:
space:
mode:
authorDixsie Wolmers <dixsie@ibm.com>2021-11-03 06:06:35 +0300
committerDixsie Wolmers <dixsiew@gmail.com>2021-12-03 23:45:37 +0300
commitb34349d4139230fb4ca99bf89a6b0e1f707e58e2 (patch)
tree06313bfae3aa3d8b2aa60ff98a89c066cb4daea8 /src/store
parentc4b8757ed88ecea369e6044548d2fbe072d5bd4a (diff)
downloadwebui-vue-b34349d4139230fb4ca99bf89a6b0e1f707e58e2.tar.xz
Network Settings: Add and Delete IPV4 and DNS address
Adds ability to add or delete static ipv4 and dns addesses per interface. Signed-off-by: Dixsie Wolmers <dixsie@ibm.com> Change-Id: Ie143ded2f173dd48f137471a684ba0d35ab0bf69
Diffstat (limited to 'src/store')
-rw-r--r--src/store/modules/Settings/NetworkStore.js119
1 files changed, 119 insertions, 0 deletions
diff --git a/src/store/modules/Settings/NetworkStore.js b/src/store/modules/Settings/NetworkStore.js
index 5b95cb00..176fcd74 100644
--- a/src/store/modules/Settings/NetworkStore.js
+++ b/src/store/modules/Settings/NetworkStore.js
@@ -7,13 +7,20 @@ const NetworkStore = {
ethernetData: [],
firstInterfaceId: '', //used for setting global DHCP settings
globalNetworkSettings: [],
+ selectedInterfaceId: '', // which tab is selected
+ selectedInterfaceIndex: 0, // which tab is selected
},
getters: {
ethernetData: (state) => state.ethernetData,
firstInterfaceId: (state) => state.firstInterfaceId,
globalNetworkSettings: (state) => state.globalNetworkSettings,
+ selectedInterfaceId: (state) => state.selectedInterfaceId,
+ selectedInterfaceIndex: (state) => state.selectedInterfaceIndex,
},
mutations: {
+ setDomainNameState: (state, domainState) =>
+ (state.domainState = domainState),
+ setDnsState: (state, dnsState) => (state.dnsState = dnsState),
setEthernetData: (state, ethernetData) =>
(state.ethernetData = ethernetData),
setFirstInterfaceId: (state, firstInterfaceId) =>
@@ -28,6 +35,7 @@ const NetworkStore = {
LinkStatus,
} = data;
return {
+ defaultGateway: IPv4StaticAddresses[0]?.Gateway, //First static gateway is the default gateway
dhcpAddress: IPv4Addresses.filter(
(ipv4) => ipv4.AddressOrigin === 'DHCP'
),
@@ -40,6 +48,11 @@ const NetworkStore = {
};
});
},
+ setNtpState: (state, ntpState) => (state.ntpState = ntpState),
+ setSelectedInterfaceId: (state, selectedInterfaceId) =>
+ (state.selectedInterfaceId = selectedInterfaceId),
+ setSelectedInterfaceIndex: (state, selectedInterfaceIndex) =>
+ (state.selectedInterfaceIndex = selectedInterfaceIndex),
},
actions: {
async getEthernetData({ commit }) {
@@ -65,6 +78,7 @@ const NetworkStore = {
commit('setEthernetData', ethernetData);
commit('setFirstInterfaceId', firstInterfaceId);
+ commit('setSelectedInterfaceId', firstInterfaceId);
commit('setGlobalNetworkSettings', ethernetInterfaces);
})
.catch((error) => {
@@ -158,6 +172,111 @@ const NetworkStore = {
);
});
},
+ async setSelectedTabIndex({ commit }, tabIndex) {
+ commit('setSelectedInterfaceIndex', tabIndex);
+ },
+ async setSelectedTabId({ commit }, tabId) {
+ commit('setSelectedInterfaceId', tabId);
+ },
+ async saveIpv4Address({ dispatch, state }, ipv4Form) {
+ const originalAddresses = state.ethernetData[
+ state.selectedInterfaceIndex
+ ].IPv4StaticAddresses.map((ipv4) => {
+ const { Address, SubnetMask, Gateway } = ipv4;
+ return {
+ Address,
+ SubnetMask,
+ Gateway,
+ };
+ });
+ const newAddress = [ipv4Form];
+ return api
+ .patch(
+ `/redfish/v1/Managers/bmc/EthernetInterfaces/${state.selectedInterfaceId}`,
+ { IPv4StaticAddresses: originalAddresses.concat(newAddress) }
+ )
+ .then(dispatch('getEthernetData'))
+ .then(() => {
+ return i18n.t('pageNetwork.toast.successSaveNetworkSettings', {
+ setting: i18n.t('pageNetwork.ipv4'),
+ });
+ })
+ .catch((error) => {
+ console.log(error);
+ throw new Error(
+ i18n.t('pageNetwork.toast.errorSaveNetworkSettings', {
+ setting: i18n.t('pageNetwork.ipv4'),
+ })
+ );
+ });
+ },
+ async editIpv4Address({ dispatch, state }, ipv4TableData) {
+ return api
+ .patch(
+ `/redfish/v1/Managers/bmc/EthernetInterfaces/${state.selectedInterfaceId}`,
+ { IPv4StaticAddresses: ipv4TableData }
+ )
+ .then(dispatch('getEthernetData'))
+ .then(() => {
+ return i18n.t('pageNetwork.toast.successSaveNetworkSettings', {
+ setting: i18n.t('pageNetwork.ipv4'),
+ });
+ })
+ .catch((error) => {
+ console.log(error);
+ throw new Error(
+ i18n.t('pageNetwork.toast.errorSaveNetworkSettings', {
+ setting: i18n.t('pageNetwork.ipv4'),
+ })
+ );
+ });
+ },
+ async saveDnsAddress({ dispatch, state }, dnsForm) {
+ const newAddress = dnsForm;
+ const originalAddresses =
+ state.ethernetData[state.selectedInterfaceIndex].StaticNameServers;
+ const newDnsArray = originalAddresses.concat(newAddress);
+ return api
+ .patch(
+ `/redfish/v1/Managers/bmc/EthernetInterfaces/${state.selectedInterfaceId}`,
+ { StaticNameServers: newDnsArray }
+ )
+ .then(dispatch('getEthernetData'))
+ .then(() => {
+ return i18n.t('pageNetwork.toast.successSaveNetworkSettings', {
+ setting: i18n.t('pageNetwork.dns'),
+ });
+ })
+ .catch((error) => {
+ console.log(error);
+ throw new Error(
+ i18n.t('pageNetwork.toast.errorSaveNetworkSettings', {
+ setting: i18n.t('pageNetwork.dns'),
+ })
+ );
+ });
+ },
+ async editDnsAddress({ dispatch, state }, dnsTableData) {
+ return api
+ .patch(
+ `/redfish/v1/Managers/bmc/EthernetInterfaces/${state.selectedInterfaceId}`,
+ { StaticNameServers: dnsTableData }
+ )
+ .then(dispatch('getEthernetData'))
+ .then(() => {
+ return i18n.t('pageNetwork.toast.successSaveNetworkSettings', {
+ setting: i18n.t('pageNetwork.dns'),
+ });
+ })
+ .catch((error) => {
+ console.log(error);
+ throw new Error(
+ i18n.t('pageNetwork.toast.errorSaveNetworkSettings', {
+ setting: i18n.t('pageNetwork.dns'),
+ })
+ );
+ });
+ },
},
};