Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 1 | /** |
| 2 | * Controller for network |
| 3 | * |
| 4 | * @module app/configuration |
| 5 | * @exports networkController |
| 6 | * @name networkController |
Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 7 | */ |
| 8 | |
Andrew Geissler | ba5e3f3 | 2018-05-24 10:58:00 -0700 | [diff] [blame] | 9 | window.angular && (function(angular) { |
| 10 | 'use strict'; |
Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 11 | |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 12 | angular.module('app.configuration').controller('networkController', [ |
Gunnar Mills | 0af165b | 2018-06-01 16:24:56 -0500 | [diff] [blame] | 13 | '$scope', '$window', 'APIUtils', 'dataService', '$timeout', '$route', '$q', |
| 14 | function($scope, $window, APIUtils, dataService, $timeout, $route, $q) { |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 15 | $scope.dataService = dataService; |
| 16 | $scope.network = {}; |
beccabroek | 067a1cd | 2018-10-05 10:25:21 -0500 | [diff] [blame] | 17 | $scope.oldInterface = {}; |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 18 | $scope.interface = {}; |
| 19 | $scope.networkDevice = false; |
| 20 | $scope.hostname = ''; |
beccabroek | 067a1cd | 2018-10-05 10:25:21 -0500 | [diff] [blame] | 21 | $scope.defaultGateway = ''; |
| 22 | $scope.setNetworkError = ''; |
| 23 | $scope.setNetworkSuccess = false; |
Gunnar Mills | 7ddc727 | 2018-04-12 16:12:03 -0500 | [diff] [blame] | 24 | $scope.selectedInterface = ''; |
beccabroek | 067a1cd | 2018-10-05 10:25:21 -0500 | [diff] [blame] | 25 | $scope.confirmSettings = false; |
Gunnar Mills | 84981f0 | 2018-05-31 15:19:01 -0500 | [diff] [blame] | 26 | $scope.loading = false; |
beccabroek | 067a1cd | 2018-10-05 10:25:21 -0500 | [diff] [blame] | 27 | $scope.ipv4sToDelete = []; |
Iftekharul Islam | 2a48955 | 2017-11-02 13:23:08 -0500 | [diff] [blame] | 28 | |
Gunnar Mills | a3f7532 | 2018-07-10 17:06:02 -0500 | [diff] [blame] | 29 | loadNetworkInfo(); |
| 30 | |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 31 | $scope.selectInterface = function(interfaceId) { |
| 32 | $scope.interface = $scope.network.interfaces[interfaceId]; |
Gunnar Mills | a45c385 | 2018-05-30 16:18:45 -0500 | [diff] [blame] | 33 | // Copy the interface so we know later if changes were made to the page |
beccabroek | 067a1cd | 2018-10-05 10:25:21 -0500 | [diff] [blame] | 34 | $scope.oldInterface = JSON.parse(JSON.stringify($scope.interface)); |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 35 | $scope.selectedInterface = interfaceId; |
| 36 | $scope.networkDevice = false; |
| 37 | }; |
Gunnar Mills | bc3ab72 | 2018-07-10 15:11:01 -0500 | [diff] [blame] | 38 | |
| 39 | $scope.addDNSField = function() { |
| 40 | $scope.interface.Nameservers.push(''); |
| 41 | }; |
| 42 | |
beccabroek | cff6150 | 2018-09-13 14:39:23 -0500 | [diff] [blame] | 43 | $scope.removeDNSField = function(index) { |
| 44 | $scope.interface.Nameservers.splice(index, 1); |
| 45 | }; |
| 46 | |
beccabroek | 1a0e7d0 | 2018-09-24 15:03:40 -0500 | [diff] [blame] | 47 | $scope.addIpv4Field = function() { |
| 48 | $scope.interface.ipv4.values.push( |
| 49 | {Address: '', PrefixLength: '', Gateway: ''}); |
| 50 | }; |
| 51 | |
beccabroek | 971ac1a | 2018-09-24 13:14:05 -0500 | [diff] [blame] | 52 | $scope.removeIpv4Address = function(index) { |
| 53 | // Check if the IPV4 being removed has an id. This indicates that it is |
| 54 | // an existing address and needs to be removed in the back end. |
| 55 | if ($scope.interface.ipv4.values[index].id) { |
beccabroek | 067a1cd | 2018-10-05 10:25:21 -0500 | [diff] [blame] | 56 | $scope.ipv4sToDelete.push($scope.interface.ipv4.values[index]); |
beccabroek | 971ac1a | 2018-09-24 13:14:05 -0500 | [diff] [blame] | 57 | } |
| 58 | $scope.interface.ipv4.values.splice(index, 1); |
| 59 | }; |
| 60 | |
Gunnar Mills | 7ddc727 | 2018-04-12 16:12:03 -0500 | [diff] [blame] | 61 | $scope.setNetworkSettings = function() { |
Gunnar Mills | d01504c | 2018-05-03 13:01:51 -0500 | [diff] [blame] | 62 | // Hides the confirm network settings modal |
beccabroek | 067a1cd | 2018-10-05 10:25:21 -0500 | [diff] [blame] | 63 | $scope.confirmSettings = false; |
| 64 | $scope.setNetworkError = ''; |
| 65 | $scope.setNetworkSuccess = false; |
Gunnar Mills | 84981f0 | 2018-05-31 15:19:01 -0500 | [diff] [blame] | 66 | $scope.loading = true; |
Gunnar Mills | dca79d7 | 2018-05-30 13:07:01 -0500 | [diff] [blame] | 67 | var promises = []; |
| 68 | |
Gunnar Mills | 659651e | 2018-05-30 15:21:07 -0500 | [diff] [blame] | 69 | // MAC Address are case-insensitive |
| 70 | if ($scope.interface.MACAddress.toLowerCase() != |
| 71 | dataService.mac_address.toLowerCase()) { |
| 72 | promises.push(setMACAddress()); |
| 73 | } |
beccabroek | 067a1cd | 2018-10-05 10:25:21 -0500 | [diff] [blame] | 74 | if ($scope.defaultGateway != dataService.defaultgateway) { |
Gunnar Mills | 659651e | 2018-05-30 15:21:07 -0500 | [diff] [blame] | 75 | promises.push(setDefaultGateway()); |
| 76 | } |
| 77 | if ($scope.hostname != dataService.hostname) { |
| 78 | promises.push(setHostname()); |
| 79 | } |
beccabroek | 067a1cd | 2018-10-05 10:25:21 -0500 | [diff] [blame] | 80 | if ($scope.interface.DHCPEnabled != $scope.oldInterface.DHCPEnabled) { |
Gunnar Mills | cb2c306 | 2018-05-31 13:13:30 -0500 | [diff] [blame] | 81 | promises.push(setDHCPEnabled()); |
| 82 | } |
Gunnar Mills | 309e06a | 2018-05-30 13:18:10 -0500 | [diff] [blame] | 83 | |
Gunnar Mills | 8265829 | 2018-06-06 16:51:32 -0500 | [diff] [blame] | 84 | // Remove any empty strings from the array. Important because we add an |
| 85 | // empty string to the end so the user can add a new DNS server, if the |
| 86 | // user doesn't fill out the field, we don't want to add. |
| 87 | $scope.interface.Nameservers = |
| 88 | $scope.interface.Nameservers.filter(Boolean); |
Gunnar Mills | 0646782 | 2018-06-06 15:43:18 -0500 | [diff] [blame] | 89 | // toString() is a cheap way to compare 2 string arrays |
| 90 | if ($scope.interface.Nameservers.toString() != |
beccabroek | 067a1cd | 2018-10-05 10:25:21 -0500 | [diff] [blame] | 91 | $scope.oldInterface.Nameservers.toString()) { |
Gunnar Mills | 0646782 | 2018-06-06 15:43:18 -0500 | [diff] [blame] | 92 | promises.push(setNameservers()); |
| 93 | } |
| 94 | |
Gunnar Mills | a45c385 | 2018-05-30 16:18:45 -0500 | [diff] [blame] | 95 | // Set IPV4 IP Addresses, Netmask Prefix Lengths, and Gateways |
| 96 | if (!$scope.interface.DHCPEnabled) { |
beccabroek | 971ac1a | 2018-09-24 13:14:05 -0500 | [diff] [blame] | 97 | // Delete existing IPV4 addresses that were removed |
| 98 | promises.push(removeIPV4s()); |
beccabroek | 1a0e7d0 | 2018-09-24 15:03:40 -0500 | [diff] [blame] | 99 | // Update any changed IPV4 addresses and add new |
Gunnar Mills | a45c385 | 2018-05-30 16:18:45 -0500 | [diff] [blame] | 100 | for (var i in $scope.interface.ipv4.values) { |
Gunnar Mills | 6549114 | 2018-06-04 14:23:33 -0500 | [diff] [blame] | 101 | if (!APIUtils.validIPV4IP( |
| 102 | $scope.interface.ipv4.values[i].Address)) { |
beccabroek | 067a1cd | 2018-10-05 10:25:21 -0500 | [diff] [blame] | 103 | $scope.setNetworkError = $scope.interface.ipv4.values[i].Address + |
Gunnar Mills | 6549114 | 2018-06-04 14:23:33 -0500 | [diff] [blame] | 104 | ' invalid IP parameter'; |
| 105 | $scope.loading = false; |
| 106 | return; |
| 107 | } |
| 108 | if (!APIUtils.validIPV4IP( |
| 109 | $scope.interface.ipv4.values[i].Gateway)) { |
beccabroek | 067a1cd | 2018-10-05 10:25:21 -0500 | [diff] [blame] | 110 | $scope.setNetworkError = $scope.interface.ipv4.values[i].Address + |
Gunnar Mills | 6549114 | 2018-06-04 14:23:33 -0500 | [diff] [blame] | 111 | ' invalid gateway parameter'; |
| 112 | $scope.loading = false; |
| 113 | return; |
| 114 | } |
| 115 | // The netmask prefix length will be undefined if outside range |
| 116 | if (!$scope.interface.ipv4.values[i].PrefixLength) { |
beccabroek | 067a1cd | 2018-10-05 10:25:21 -0500 | [diff] [blame] | 117 | $scope.setNetworkError = $scope.interface.ipv4.values[i].Address + |
Gunnar Mills | 6549114 | 2018-06-04 14:23:33 -0500 | [diff] [blame] | 118 | ' invalid Prefix Length parameter'; |
| 119 | $scope.loading = false; |
| 120 | return; |
| 121 | } |
beccabroek | 067a1cd | 2018-10-05 10:25:21 -0500 | [diff] [blame] | 122 | if ($scope.interface.ipv4.values[i].updateAddress || |
| 123 | $scope.interface.ipv4.values[i].updateGateway || |
| 124 | $scope.interface.ipv4.values[i].updatePrefix) { |
beccabroek | 1a0e7d0 | 2018-09-24 15:03:40 -0500 | [diff] [blame] | 125 | // If IPV4 has an id it means it already exists in the back end, |
| 126 | // and in order to update it is required to remove previous IPV4 |
| 127 | // address and add new one. See openbmc/openbmc/issues/2163. |
| 128 | // TODO: update to use PUT once issue 2163 is resolved. |
| 129 | if ($scope.interface.ipv4.values[i].id) { |
| 130 | promises.push(updateIPV4(i)); |
| 131 | } else { |
| 132 | promises.push(addIPV4(i)); |
| 133 | } |
Gunnar Mills | a45c385 | 2018-05-30 16:18:45 -0500 | [diff] [blame] | 134 | } |
| 135 | } |
| 136 | } |
| 137 | |
Gunnar Mills | 0af165b | 2018-06-01 16:24:56 -0500 | [diff] [blame] | 138 | if (promises.length) { |
| 139 | $q.all(promises).finally(function() { |
| 140 | $scope.loading = false; |
beccabroek | 067a1cd | 2018-10-05 10:25:21 -0500 | [diff] [blame] | 141 | if (!$scope.setNetworkError) { |
| 142 | $scope.setNetworkSuccess = true; |
Gunnar Mills | 0af165b | 2018-06-01 16:24:56 -0500 | [diff] [blame] | 143 | // Since an IPV4 interface (e.g. IP address, gateway, or netmask) |
| 144 | // edit is a delete then an add and the GUI can't calculate the |
| 145 | // interface id (e.g. 5c083707) beforehand and it is not returned |
| 146 | // by the REST call, openbmc#3227, reload the page after an edit, |
| 147 | // which makes a 2nd REST call. |
| 148 | // Do this for all network changes due to the possibility of a set |
| 149 | // network failing even though it returned success, openbmc#1641, |
beccabroek | 067a1cd | 2018-10-05 10:25:21 -0500 | [diff] [blame] | 150 | // and to update dataService and oldInterface to know which |
Gunnar Mills | 0af165b | 2018-06-01 16:24:56 -0500 | [diff] [blame] | 151 | // data has changed if the user continues to edit network |
| 152 | // settings. |
| 153 | // TODO: The reload is not ideal. Revisit this. |
| 154 | $timeout(function() { |
Gunnar Mills | a3f7532 | 2018-07-10 17:06:02 -0500 | [diff] [blame] | 155 | loadNetworkInfo(); |
Gunnar Mills | 0af165b | 2018-06-01 16:24:56 -0500 | [diff] [blame] | 156 | }, 4000); |
| 157 | } |
| 158 | }); |
| 159 | } else { |
Gunnar Mills | 84981f0 | 2018-05-31 15:19:01 -0500 | [diff] [blame] | 160 | $scope.loading = false; |
Gunnar Mills | 0af165b | 2018-06-01 16:24:56 -0500 | [diff] [blame] | 161 | } |
Gunnar Mills | dca79d7 | 2018-05-30 13:07:01 -0500 | [diff] [blame] | 162 | }; |
| 163 | |
| 164 | function setMACAddress() { |
| 165 | return APIUtils |
Gunnar Mills | 7ddc727 | 2018-04-12 16:12:03 -0500 | [diff] [blame] | 166 | .setMACAddress( |
| 167 | $scope.selectedInterface, $scope.interface.MACAddress) |
| 168 | .then( |
Gunnar Mills | dca79d7 | 2018-05-30 13:07:01 -0500 | [diff] [blame] | 169 | function(data) {}, |
Gunnar Mills | 7ddc727 | 2018-04-12 16:12:03 -0500 | [diff] [blame] | 170 | function(error) { |
Gunnar Mills | dca79d7 | 2018-05-30 13:07:01 -0500 | [diff] [blame] | 171 | console.log(JSON.stringify(error)); |
beccabroek | 067a1cd | 2018-10-05 10:25:21 -0500 | [diff] [blame] | 172 | $scope.setNetworkError = 'MAC Address'; |
Gunnar Mills | 7ddc727 | 2018-04-12 16:12:03 -0500 | [diff] [blame] | 173 | }); |
Gunnar Mills | dca79d7 | 2018-05-30 13:07:01 -0500 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | function setDefaultGateway() { |
beccabroek | 067a1cd | 2018-10-05 10:25:21 -0500 | [diff] [blame] | 177 | return APIUtils.setDefaultGateway($scope.defaultGateway) |
Gunnar Mills | dca79d7 | 2018-05-30 13:07:01 -0500 | [diff] [blame] | 178 | .then( |
| 179 | function(data) {}, |
| 180 | function(error) { |
| 181 | console.log(JSON.stringify(error)); |
beccabroek | 067a1cd | 2018-10-05 10:25:21 -0500 | [diff] [blame] | 182 | $scope.setNetworkError = 'Default Gateway'; |
Gunnar Mills | dca79d7 | 2018-05-30 13:07:01 -0500 | [diff] [blame] | 183 | }); |
| 184 | } |
Gunnar Mills | 309e06a | 2018-05-30 13:18:10 -0500 | [diff] [blame] | 185 | |
| 186 | function setHostname() { |
| 187 | return APIUtils.setHostname($scope.hostname) |
| 188 | .then( |
| 189 | function(data) {}, |
| 190 | function(error) { |
| 191 | console.log(JSON.stringify(error)); |
beccabroek | 067a1cd | 2018-10-05 10:25:21 -0500 | [diff] [blame] | 192 | $scope.setNetworkError = 'Hostname'; |
Gunnar Mills | 309e06a | 2018-05-30 13:18:10 -0500 | [diff] [blame] | 193 | }); |
| 194 | } |
| 195 | |
Gunnar Mills | cb2c306 | 2018-05-31 13:13:30 -0500 | [diff] [blame] | 196 | function setDHCPEnabled() { |
| 197 | return APIUtils |
| 198 | .setDHCPEnabled( |
| 199 | $scope.selectedInterface, $scope.interface.DHCPEnabled) |
| 200 | .then( |
| 201 | function(data) {}, |
| 202 | function(error) { |
| 203 | console.log(JSON.stringify(error)); |
beccabroek | 067a1cd | 2018-10-05 10:25:21 -0500 | [diff] [blame] | 204 | $scope.setNetworkError = 'DHCP'; |
Gunnar Mills | cb2c306 | 2018-05-31 13:13:30 -0500 | [diff] [blame] | 205 | }); |
| 206 | } |
| 207 | |
Gunnar Mills | 0646782 | 2018-06-06 15:43:18 -0500 | [diff] [blame] | 208 | function setNameservers() { |
Gunnar Mills | 8265829 | 2018-06-06 16:51:32 -0500 | [diff] [blame] | 209 | // Nameservers does not allow an empty array, since we remove all empty |
Gunnar Mills | 9863d12 | 2018-07-11 13:36:43 -0500 | [diff] [blame] | 210 | // strings above, could have an empty array. TODO: openbmc/openbmc#3240 |
Gunnar Mills | 8265829 | 2018-06-06 16:51:32 -0500 | [diff] [blame] | 211 | if ($scope.interface.Nameservers.length == 0) { |
| 212 | $scope.interface.Nameservers.push(''); |
| 213 | } |
Gunnar Mills | 0646782 | 2018-06-06 15:43:18 -0500 | [diff] [blame] | 214 | return APIUtils |
| 215 | .setNameservers( |
| 216 | $scope.selectedInterface, $scope.interface.Nameservers) |
| 217 | .then( |
| 218 | function(data) {}, |
| 219 | function(error) { |
| 220 | console.log(JSON.stringify(error)); |
beccabroek | 067a1cd | 2018-10-05 10:25:21 -0500 | [diff] [blame] | 221 | $scope.setNetworkError = 'DNS Servers'; |
Gunnar Mills | 0646782 | 2018-06-06 15:43:18 -0500 | [diff] [blame] | 222 | }); |
| 223 | } |
| 224 | |
beccabroek | 971ac1a | 2018-09-24 13:14:05 -0500 | [diff] [blame] | 225 | function removeIPV4s() { |
beccabroek | 067a1cd | 2018-10-05 10:25:21 -0500 | [diff] [blame] | 226 | return $scope.ipv4sToDelete.map(function(ipv4) { |
beccabroek | 971ac1a | 2018-09-24 13:14:05 -0500 | [diff] [blame] | 227 | return APIUtils.deleteIPV4($scope.selectedInterface, ipv4.id) |
| 228 | .then( |
| 229 | function(data) {}, |
| 230 | function(error) { |
| 231 | console.log(JSON.stringify(error)); |
beccabroek | 067a1cd | 2018-10-05 10:25:21 -0500 | [diff] [blame] | 232 | $scope.setNetworkError = ipv4.Address; |
beccabroek | 971ac1a | 2018-09-24 13:14:05 -0500 | [diff] [blame] | 233 | }) |
| 234 | }); |
| 235 | } |
| 236 | |
beccabroek | 1a0e7d0 | 2018-09-24 15:03:40 -0500 | [diff] [blame] | 237 | function addIPV4(index) { |
| 238 | return APIUtils |
| 239 | .addIPV4( |
| 240 | $scope.selectedInterface, |
| 241 | $scope.interface.ipv4.values[index].Address, |
| 242 | $scope.interface.ipv4.values[index].PrefixLength, |
| 243 | $scope.interface.ipv4.values[index].Gateway) |
| 244 | .then( |
| 245 | function(data) {}, |
| 246 | function(error) { |
| 247 | console.log(JSON.stringify(error)); |
beccabroek | 067a1cd | 2018-10-05 10:25:21 -0500 | [diff] [blame] | 248 | $scope.setNetworkError = |
beccabroek | 1a0e7d0 | 2018-09-24 15:03:40 -0500 | [diff] [blame] | 249 | $scope.interface.ipv4.values[index].Address; |
| 250 | }) |
| 251 | } |
| 252 | |
| 253 | function updateIPV4(index) { |
Gunnar Mills | a45c385 | 2018-05-30 16:18:45 -0500 | [diff] [blame] | 254 | // The correct way to edit an IPV4 interface is to remove it and then |
| 255 | // add a new one |
| 256 | return APIUtils |
| 257 | .deleteIPV4( |
beccabroek | 1a0e7d0 | 2018-09-24 15:03:40 -0500 | [diff] [blame] | 258 | $scope.selectedInterface, |
| 259 | $scope.interface.ipv4.values[index].id) |
Gunnar Mills | a45c385 | 2018-05-30 16:18:45 -0500 | [diff] [blame] | 260 | .then( |
| 261 | function(data) { |
| 262 | return APIUtils |
| 263 | .addIPV4( |
| 264 | $scope.selectedInterface, |
| 265 | $scope.interface.ipv4.values[index].Address, |
| 266 | $scope.interface.ipv4.values[index].PrefixLength, |
| 267 | $scope.interface.ipv4.values[index].Gateway) |
| 268 | .then( |
| 269 | function(data) {}, |
| 270 | function(error) { |
| 271 | console.log(JSON.stringify(error)); |
beccabroek | 067a1cd | 2018-10-05 10:25:21 -0500 | [diff] [blame] | 272 | $scope.setNetworkError = |
Gunnar Mills | a45c385 | 2018-05-30 16:18:45 -0500 | [diff] [blame] | 273 | $scope.interface.ipv4.values[index].Address; |
| 274 | }); |
| 275 | }, |
| 276 | function(error) { |
| 277 | console.log(JSON.stringify(error)); |
beccabroek | 067a1cd | 2018-10-05 10:25:21 -0500 | [diff] [blame] | 278 | $scope.setNetworkError = |
Gunnar Mills | a45c385 | 2018-05-30 16:18:45 -0500 | [diff] [blame] | 279 | $scope.interface.ipv4.values[index].Address; |
| 280 | }); |
| 281 | } |
| 282 | |
Gunnar Mills | 9a0094d | 2018-05-02 21:50:56 -0500 | [diff] [blame] | 283 | $scope.refresh = function() { |
Gunnar Mills | a3f7532 | 2018-07-10 17:06:02 -0500 | [diff] [blame] | 284 | loadNetworkInfo(); |
Gunnar Mills | 9a0094d | 2018-05-02 21:50:56 -0500 | [diff] [blame] | 285 | }; |
Gunnar Mills | a3f7532 | 2018-07-10 17:06:02 -0500 | [diff] [blame] | 286 | |
| 287 | function loadNetworkInfo() { |
| 288 | APIUtils.getNetworkInfo().then(function(data) { |
| 289 | dataService.setNetworkInfo(data); |
| 290 | $scope.network = data.formatted_data; |
| 291 | $scope.hostname = data.hostname; |
beccabroek | 067a1cd | 2018-10-05 10:25:21 -0500 | [diff] [blame] | 292 | $scope.defaultGateway = data.defaultgateway; |
Gunnar Mills | a3f7532 | 2018-07-10 17:06:02 -0500 | [diff] [blame] | 293 | if ($scope.network.interface_ids.length) { |
Rebecca Shaw | ffdef96 | 2018-07-19 13:37:37 -0500 | [diff] [blame] | 294 | // Use the first network interface if the user hasn't chosen one |
Gunnar Mills | a3f7532 | 2018-07-10 17:06:02 -0500 | [diff] [blame] | 295 | if (!$scope.selectedInterface || |
| 296 | !$scope.network.interfaces[$scope.selectedInterface]) { |
| 297 | $scope.selectedInterface = $scope.network.interface_ids[0]; |
| 298 | } |
| 299 | $scope.interface = |
| 300 | $scope.network.interfaces[$scope.selectedInterface]; |
| 301 | // Copy the interface so we know later if changes were made to the |
| 302 | // page |
beccabroek | 067a1cd | 2018-10-05 10:25:21 -0500 | [diff] [blame] | 303 | $scope.oldInterface = JSON.parse(JSON.stringify($scope.interface)); |
Gunnar Mills | a3f7532 | 2018-07-10 17:06:02 -0500 | [diff] [blame] | 304 | } |
beccabroek | 1a0e7d0 | 2018-09-24 15:03:40 -0500 | [diff] [blame] | 305 | // Add id values and update flags to corresponding IPV4 objects |
beccabroek | 971ac1a | 2018-09-24 13:14:05 -0500 | [diff] [blame] | 306 | for (var i = 0; i < $scope.interface.ipv4.values.length; i++) { |
| 307 | $scope.interface.ipv4.values[i].id = $scope.interface.ipv4.ids[i]; |
beccabroek | 067a1cd | 2018-10-05 10:25:21 -0500 | [diff] [blame] | 308 | $scope.interface.ipv4.values[i].updateAddress = false; |
| 309 | $scope.interface.ipv4.values[i].updateGateway = false; |
| 310 | $scope.interface.ipv4.values[i].updatePrefix = false; |
beccabroek | 971ac1a | 2018-09-24 13:14:05 -0500 | [diff] [blame] | 311 | } |
Gunnar Mills | a3f7532 | 2018-07-10 17:06:02 -0500 | [diff] [blame] | 312 | }); |
| 313 | } |
Andrew Geissler | d27bb13 | 2018-05-24 11:07:27 -0700 | [diff] [blame] | 314 | } |
| 315 | ]); |
Iftekharul Islam | cd78950 | 2017-04-19 14:37:55 -0500 | [diff] [blame] | 316 | })(angular); |