From c4b8757ed88ecea369e6044548d2fbe072d5bd4a Mon Sep 17 00:00:00 2001 From: Dixsie Wolmers Date: Thu, 7 Oct 2021 16:15:50 -0500 Subject: Network settings redesign - interface settings First commit of the network settings redesign: - Adds the global network settings section for DHCP settings - Adds read only hostname, FQDN and MAC address, modal to edit each will be done seperately - Removes interface specific sections to refactor in next commit - Adds tab component to display ethernet data by interface - Ability to edit, delete and add ipv4 addresses and DNS will be done in separate commit Signed-off-by: Dixsie Wolmers Change-Id: Ibb1db6894ee697fec9e6ea1b8312d041c61faaad --- src/locales/en-US.json | 55 +- src/main.js | 2 + src/store/modules/Settings/NetworkStore.js | 148 +++-- src/views/Settings/Network/Network.vue | 683 ++------------------- .../Settings/Network/NetworkGlobalSettings.vue | 152 +++++ .../Settings/Network/NetworkInterfaceSettings.vue | 99 +++ src/views/Settings/Network/TableDns.vue | 126 ++++ src/views/Settings/Network/TableIpv4.vue | 146 +++++ 8 files changed, 705 insertions(+), 706 deletions(-) create mode 100644 src/views/Settings/Network/NetworkGlobalSettings.vue create mode 100644 src/views/Settings/Network/NetworkInterfaceSettings.vue create mode 100644 src/views/Settings/Network/TableDns.vue create mode 100644 src/views/Settings/Network/TableIpv4.vue diff --git a/src/locales/en-US.json b/src/locales/en-US.json index 7e35d450..3bfc4a88 100644 --- a/src/locales/en-US.json +++ b/src/locales/en-US.json @@ -630,38 +630,43 @@ }, "pageNetwork": { "dhcp": "DHCP", - "ipv4": "IPV4", - "ipv4Configuration": "IPV4 configuration", - "ipv4Helper": "An IP address must be available to enable DHCP or Static configuration", - "interface": "Interface", - "pageDescription": "Configure network settings for the BMC", - "static": "Static", + "domainName": "domain name", + "dns": "DNS server", + "fqdn": "FQDN", + "hostname": "Hostname", + "interfaceSection": "Interface settings", + "ipv4": "IPv4", + "ipv4Addresses": "IPv4 addresses", + "ipv6": "IPv6", + "linkStatus": "Link status", + "macAddress": "MAC address", + "networkSettings": "Network settings", + "ntp": "NTP server", + "pageDescription": "Configure BMC network settings", + "useDns": "Use DNS servers", + "useDomainName": "Use domain name", + "useNtp": "Use NTP servers", + "speed": "Speed (mbps)", "staticDns": "Static DNS", - "system": "System", - "form": { - "defaultGateway": "Default gateway", - "hostname": "Hostname", - "macAddress": "MAC address", - "networkInterface": "Network interface" + "modal": { + "ipAddress": "IP address", + "gateway": "Gateway", + "subnetMask": "Subnet mask" }, "table": { - "addDns": "Add DNS server", - "addStaticIpv4Address": "Add static IP", - "deleteDhcpIpv4": "Delete IPv4 row", - "deleteDns": "Delete DNS row", - "deleteStaticIpv4": "Delete IPv4 row", - "dhcpIpv4AddressRow": "DHCP IPv4 address", - "dhcpIpv4SubnetRow": "DHCP IPV4 subnet", + "addIpv4Address": "Add static IPv4 address", + "addressOrigin": "Address origin", + "deleteDns": "Edit DNS address", + "deleteIpv4": "Edit IPv4 address", + "editDns": "Edit DNS address", + "editIpv4": "Edit IPv4 address", + "gateway": "Gateway", "ipAddress": "IP address", - "staticDnsRow": "Static DNS address", - "staticIpv4AddressRow": "Static IPv4 address", - "staticIpv4SubnetRow": "Static IPV4 subnet", "subnet": "Subnet mask" }, "toast": { - "errorSaveDhcpSettings": "Error enabling DHCP configuration.", - "errorSaveNetworkSettings": "Error saving network settings.", - "successSaveNetworkSettings": "Successfully saved network settings." + "errorSaveNetworkSettings": "Error updating %{setting} settings.", + "successSaveNetworkSettings": "Successfully updated %{setting} settings." } }, "pagePageNotFound": { diff --git a/src/main.js b/src/main.js index 8fcb8089..0aae716f 100644 --- a/src/main.js +++ b/src/main.js @@ -34,6 +34,7 @@ import { PaginationPlugin, ProgressPlugin, TablePlugin, + TabsPlugin, ToastPlugin, TooltipPlugin, } from 'bootstrap-vue'; @@ -123,6 +124,7 @@ Vue.use(NavPlugin); Vue.use(PaginationPlugin); Vue.use(ProgressPlugin); Vue.use(TablePlugin); +Vue.use(TabsPlugin); Vue.use(ToastPlugin); Vue.use(TooltipPlugin); Vue.use(Vuelidate); diff --git a/src/store/modules/Settings/NetworkStore.js b/src/store/modules/Settings/NetworkStore.js index 65a83b44..5b95cb00 100644 --- a/src/store/modules/Settings/NetworkStore.js +++ b/src/store/modules/Settings/NetworkStore.js @@ -1,43 +1,42 @@ import api from '@/store/api'; import i18n from '@/i18n'; -import { find, remove } from 'lodash'; const NetworkStore = { namespaced: true, state: { - defaultGateway: '', ethernetData: [], - interfaceOptions: [], + firstInterfaceId: '', //used for setting global DHCP settings globalNetworkSettings: [], }, getters: { - defaultGateway: (state) => state.defaultGateway, ethernetData: (state) => state.ethernetData, - interfaceOptions: (state) => state.interfaceOptions, + firstInterfaceId: (state) => state.firstInterfaceId, globalNetworkSettings: (state) => state.globalNetworkSettings, }, mutations: { - setDefaultGateway: (state, defaultGateway) => - (state.defaultGateway = defaultGateway), setEthernetData: (state, ethernetData) => (state.ethernetData = ethernetData), - setInterfaceOptions: (state, interfaceOptions) => - (state.interfaceOptions = interfaceOptions), + setFirstInterfaceId: (state, firstInterfaceId) => + (state.firstInterfaceId = firstInterfaceId), setGlobalNetworkSettings: (state, data) => { state.globalNetworkSettings = data.map(({ data }) => { const { + DHCPv4, HostName, - LinkStatus, - IPv4StaticAddresses, IPv4Addresses, + IPv4StaticAddresses, + LinkStatus, } = data; return { - hostname: HostName, - linkStatus: LinkStatus, - staticAddress: IPv4StaticAddresses[0]?.Address, dhcpAddress: IPv4Addresses.filter( (ipv4) => ipv4.AddressOrigin === 'DHCP' ), + hostname: HostName, + linkStatus: LinkStatus, + staticAddress: IPv4StaticAddresses[0]?.Address, // Display first static address on overview page + useDnsEnabled: DHCPv4.UseDNSServers, + useDomainNameEnabled: DHCPv4.UseDomainName, + useNtpEnabled: DHCPv4.UseNTPServers, }; }); }, @@ -62,70 +61,101 @@ const NetworkStore = { const ethernetData = ethernetInterfaces.map( (ethernetInterface) => ethernetInterface.data ); - const interfaceOptions = ethernetInterfaces.map( - (ethernetName) => ethernetName.data.Id - ); - const addresses = ethernetData[0].IPv4StaticAddresses; - - // Default gateway manually set to first gateway saved on the first interface. Default gateway property is WIP on backend - const defaultGateway = addresses.map((ipv4) => { - return ipv4.Gateway; - }); + const firstInterfaceId = ethernetData[0].Id; - commit('setGlobalNetworkSettings', ethernetInterfaces); - commit('setDefaultGateway', defaultGateway[0]); commit('setEthernetData', ethernetData); - commit('setInterfaceOptions', interfaceOptions); + commit('setFirstInterfaceId', firstInterfaceId); + commit('setGlobalNetworkSettings', ethernetInterfaces); }) .catch((error) => { console.log('Network Data:', error); }); }, - - async updateInterfaceSettings({ dispatch, state }, networkSettingsForm) { - const updatedAddresses = networkSettingsForm.staticIpv4; - const originalAddresses = - state.ethernetData[networkSettingsForm.selectedInterfaceIndex] - .IPv4StaticAddresses; - - const addressArray = originalAddresses.map((item) => { - const address = item.Address; - if (find(updatedAddresses, { Address: address })) { - remove(updatedAddresses, (item) => { - return item.Address === address; + async saveDomainNameState({ commit, state }, domainState) { + commit('setDomainNameState', domainState); + const data = { + DHCPv4: { + UseDomainName: domainState, + }, + }; + // Saving to the first interface automatically updates DHCPv4 and DHCPv6 + // on all interfaces + return api + .patch( + `/redfish/v1/Managers/bmc/EthernetInterfaces/${state.firstInterfaceId}`, + data + ) + .then(() => { + return i18n.t('pageNetwork.toast.successSaveNetworkSettings', { + setting: i18n.t('pageNetwork.domainName'), }); - return {}; - } else { - return null; - } - }); - + }) + .catch((error) => { + console.log(error); + commit('setDomainNameState', !domainState); + throw new Error( + i18n.t('pageNetwork.toast.errorSaveNetworkSettings', { + setting: i18n.t('pageNetwork.domainName'), + }) + ); + }); + }, + async saveDnsState({ commit, state }, dnsState) { + commit('setDnsState', dnsState); const data = { - HostName: networkSettingsForm.hostname, - MACAddress: networkSettingsForm.macAddress, DHCPv4: { - DHCPEnabled: networkSettingsForm.isDhcpEnabled, + UseDNSServers: dnsState, }, }; - - // If DHCP disabled, update static DNS or static ipv4 - if (!networkSettingsForm.isDhcpEnabled) { - data.IPv4StaticAddresses = [...addressArray, ...updatedAddresses]; - data.StaticNameServers = networkSettingsForm.staticNameServers; - } - - return await api + // Saving to the first interface automatically updates DHCPv4 and DHCPv6 + // on all interfaces + return api .patch( - `/redfish/v1/Managers/bmc/EthernetInterfaces/${networkSettingsForm.interfaceId}`, + `/redfish/v1/Managers/bmc/EthernetInterfaces/${state.firstInterfaceId}`, data ) - .then(() => dispatch('getEthernetData')) .then(() => { - return i18n.t('pageNetwork.toast.successSaveNetworkSettings'); + return i18n.t('pageNetwork.toast.successSaveNetworkSettings', { + setting: i18n.t('pageNetwork.dns'), + }); }) .catch((error) => { console.log(error); - throw new Error(i18n.t('pageNetwork.toast.errorSaveNetworkSettings')); + commit('setDnsState', !dnsState); + throw new Error( + i18n.t('pageNetwork.toast.errorSaveNetworkSettings', { + setting: i18n.t('pageNetwork.dns'), + }) + ); + }); + }, + async saveNtpState({ commit, state }, ntpState) { + commit('setNtpState', ntpState); + const data = { + DHCPv4: { + UseDNSServers: ntpState, + }, + }; + // Saving to the first interface automatically updates DHCPv4 and DHCPv6 + // on all interfaces + return api + .patch( + `/redfish/v1/Managers/bmc/EthernetInterfaces/${state.firstInterfaceId}`, + data + ) + .then(() => { + return i18n.t('pageNetwork.toast.successSaveNetworkSettings', { + setting: i18n.t('pageNetwork.ntp'), + }); + }) + .catch((error) => { + console.log(error); + commit('setNtpState', !ntpState); + throw new Error( + i18n.t('pageNetwork.toast.errorSaveNetworkSettings', { + setting: i18n.t('pageNetwork.ntp'), + }) + ); }); }, }, diff --git a/src/views/Settings/Network/Network.vue b/src/views/Settings/Network/Network.vue index ab5003f8..918c8e98 100644 --- a/src/views/Settings/Network/Network.vue +++ b/src/views/Settings/Network/Network.vue @@ -1,663 +1,102 @@ diff --git a/src/views/Settings/Network/NetworkInterfaceSettings.vue b/src/views/Settings/Network/NetworkInterfaceSettings.vue new file mode 100644 index 00000000..bdcba4d8 --- /dev/null +++ b/src/views/Settings/Network/NetworkInterfaceSettings.vue @@ -0,0 +1,99 @@ + + + diff --git a/src/views/Settings/Network/TableDns.vue b/src/views/Settings/Network/TableDns.vue new file mode 100644 index 00000000..2578ba36 --- /dev/null +++ b/src/views/Settings/Network/TableDns.vue @@ -0,0 +1,126 @@ + + + diff --git a/src/views/Settings/Network/TableIpv4.vue b/src/views/Settings/Network/TableIpv4.vue new file mode 100644 index 00000000..5e4bb7b5 --- /dev/null +++ b/src/views/Settings/Network/TableIpv4.vue @@ -0,0 +1,146 @@ + + + -- cgit v1.2.3