Add "Add new DNS server" button
Added a button which allows the user to add new DNS Servers.
After pressing the button a new empty field appears.
Resolves openbmc/openbmc#3089
Tested: Added several new DNS Servers on a Witherspoon.
Change-Id: Ic6a6d2b798ad177b0e9aeb64ba3e4993af442305
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
diff --git a/app/configuration/controllers/network-controller.js b/app/configuration/controllers/network-controller.js
index 4e8a7e0..b0daefd 100644
--- a/app/configuration/controllers/network-controller.js
+++ b/app/configuration/controllers/network-controller.js
@@ -55,6 +55,11 @@
promises.push(setDHCPEnabled());
}
+ // Remove any empty strings from the array. Important because we add an
+ // empty string to the end so the user can add a new DNS server, if the
+ // user doesn't fill out the field, we don't want to add.
+ $scope.interface.Nameservers =
+ $scope.interface.Nameservers.filter(Boolean);
// toString() is a cheap way to compare 2 string arrays
if ($scope.interface.Nameservers.toString() !=
$scope.old_interface.Nameservers.toString()) {
@@ -171,6 +176,11 @@
}
function setNameservers() {
+ // Nameservers does not allow an empty array, since we remove all empty
+ // strings above, could have an empty array.
+ if ($scope.interface.Nameservers.length == 0) {
+ $scope.interface.Nameservers.push('');
+ }
return APIUtils
.setNameservers(
$scope.selectedInterface, $scope.interface.Nameservers)