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