Update code styling for network page
Now that the following style guide is being
used:
https://google.github.io/styleguide/jsguide.html#naming
Some of the variable naming in this class needs to be updated.
Change-Id: I6ca7a0ea7255ab2314bb4b5fc2d89cff9006039a
Signed-off-by: beccabroek <beccabroek@gmail.com>
diff --git a/app/configuration/controllers/network-controller.html b/app/configuration/controllers/network-controller.html
index 4b75b28..83e37d7 100644
--- a/app/configuration/controllers/network-controller.html
+++ b/app/configuration/controllers/network-controller.html
@@ -30,7 +30,7 @@
</div>
<div class="column small-12 large-3">
<label for="net-config__domain">Default Gateway</label>
- <input id="net-config__domain" type="text" ng-model="defaultgateway"/>
+ <input id="net-config__domain" type="text" ng-model="defaultGateway"/>
</div>
</fieldset>
</section>
@@ -55,16 +55,16 @@
<fieldset class="net-config__static-ip-wrap" ng-repeat="ipv4 in interface.ipv4.values track by $index">
<div class="column small-12 large-3">
<label>IPV4 address</label>
- <input id="ipv4-address-{{$index+1}}" ng-change="ipv4.update_address = true" type="text" ng-disabled="interface.DHCPEnabled" ng-model="ipv4.Address"/>
+ <input id="ipv4-address-{{$index+1}}" ng-change="ipv4.updateAddress = true" type="text" ng-disabled="interface.DHCPEnabled" ng-model="ipv4.Address"/>
</div>
<div class="column small-12 large-3">
<label>Gateway</label>
- <input id="ipv4-gateway-{{$index+1}}" ng-change="ipv4.update_gateway = true" type="text" ng-disabled="interface.DHCPEnabled" value="" ng-model="ipv4.Gateway"/>
+ <input id="ipv4-gateway-{{$index+1}}" ng-change="ipv4.updateGateway = true" type="text" ng-disabled="interface.DHCPEnabled" value="" ng-model="ipv4.Gateway"/>
</div>
<!-- This netmask prefix length max only works with IPV4 -->
<div class="column small-12 large-6">
<label>Netmask Prefix Length</label>
- <input id="ipv4-prefix-{{$index+1}}" class="column small-6" ng-change="ipv4.update_prefix = true" type="number" min="1" max="32" step="1" ng-disabled="interface.DHCPEnabled" ng-model="ipv4.PrefixLength"/>
+ <input id="ipv4-prefix-{{$index+1}}" class="column small-6" ng-change="ipv4.updatePrefix = true" type="number" min="1" max="32" step="1" ng-disabled="interface.DHCPEnabled" ng-model="ipv4.PrefixLength"/>
<button class="network-config_remove-button inline" ng-click="removeIpv4Address($index)">Remove</button>
</div>
</fieldset>
@@ -96,15 +96,15 @@
</div>
</fieldset>
<div class="network-config__submit-wrapper">
- <button type="button" class="btn-primary inline" ng-click="confirm_settings=true;">Save settings</button>
+ <button type="button" class="btn-primary inline" ng-click="confirmSettings=true;">Save settings</button>
<button type="button" class="btn-secondary inline" ng-click="refresh()">Cancel</button>
</div>
- <p class="success-msg set_network_success" ng-show="set_network_success" role="alert">Success! Network settings changed!</p>
- <p class="set_network_error error-msg" ng-show="set_network_error" role="alert">Error setting {{set_network_error}}!</p>
+ <p class="success-msg set_network_success" ng-show="setNetworkSuccess" role="alert">Success! Network settings changed!</p>
+ <p class="set_network_error error-msg" ng-show="setNetworkError" role="alert">Error setting {{setNetworkError}}!</p>
</section>
</form>
</div>
-<section class="modal" aria-hidden="true" aria-labelledby="modalTitle" aria-describedby="modalDescription" role="dialog" ng-class="{'active': confirm_settings}">
+<section class="modal" aria-hidden="true" aria-labelledby="modalTitle" aria-describedby="modalDescription" role="dialog" ng-class="{'active': confirmSettings}">
<div class="modal__tftp-unreachable" role="document">
<div class="screen-reader-offscreen modal-description">Change network settings</div><!-- accessibility only; used for screen readers -->
<div class="page-header ">
@@ -116,7 +116,7 @@
Proceed with caution and make note of any new settings that may affect connectivity.</p>
</div>
<div class="modal__button-wrapper">
- <button class="inline btn-secondary" ng-click="confirm_settings=false;">Cancel</button>
+ <button class="inline btn-secondary" ng-click="confirmSettings=false;">Cancel</button>
<button class="inline btn-primary" ng-click="setNetworkSettings()">Continue</button>
</div>
</div>
diff --git a/app/configuration/controllers/network-controller.js b/app/configuration/controllers/network-controller.js
index 92da0b2..da40a47 100644
--- a/app/configuration/controllers/network-controller.js
+++ b/app/configuration/controllers/network-controller.js
@@ -14,24 +14,24 @@
function($scope, $window, APIUtils, dataService, $timeout, $route, $q) {
$scope.dataService = dataService;
$scope.network = {};
- $scope.old_interface = {};
+ $scope.oldInterface = {};
$scope.interface = {};
$scope.networkDevice = false;
$scope.hostname = '';
- $scope.defaultgateway = '';
- $scope.set_network_error = '';
- $scope.set_network_success = false;
+ $scope.defaultGateway = '';
+ $scope.setNetworkError = '';
+ $scope.setNetworkSuccess = false;
$scope.selectedInterface = '';
- $scope.confirm_settings = false;
+ $scope.confirmSettings = false;
$scope.loading = false;
- $scope.IPV4s_to_delete = [];
+ $scope.ipv4sToDelete = [];
loadNetworkInfo();
$scope.selectInterface = function(interfaceId) {
$scope.interface = $scope.network.interfaces[interfaceId];
// Copy the interface so we know later if changes were made to the page
- $scope.old_interface = JSON.parse(JSON.stringify($scope.interface));
+ $scope.oldInterface = JSON.parse(JSON.stringify($scope.interface));
$scope.selectedInterface = interfaceId;
$scope.networkDevice = false;
};
@@ -53,16 +53,16 @@
// Check if the IPV4 being removed has an id. This indicates that it is
// an existing address and needs to be removed in the back end.
if ($scope.interface.ipv4.values[index].id) {
- $scope.IPV4s_to_delete.push($scope.interface.ipv4.values[index]);
+ $scope.ipv4sToDelete.push($scope.interface.ipv4.values[index]);
}
$scope.interface.ipv4.values.splice(index, 1);
};
$scope.setNetworkSettings = function() {
// Hides the confirm network settings modal
- $scope.confirm_settings = false;
- $scope.set_network_error = '';
- $scope.set_network_success = false;
+ $scope.confirmSettings = false;
+ $scope.setNetworkError = '';
+ $scope.setNetworkSuccess = false;
$scope.loading = true;
var promises = [];
@@ -71,13 +71,13 @@
dataService.mac_address.toLowerCase()) {
promises.push(setMACAddress());
}
- if ($scope.defaultgateway != dataService.defaultgateway) {
+ if ($scope.defaultGateway != dataService.defaultgateway) {
promises.push(setDefaultGateway());
}
if ($scope.hostname != dataService.hostname) {
promises.push(setHostname());
}
- if ($scope.interface.DHCPEnabled != $scope.old_interface.DHCPEnabled) {
+ if ($scope.interface.DHCPEnabled != $scope.oldInterface.DHCPEnabled) {
promises.push(setDHCPEnabled());
}
@@ -88,7 +88,7 @@
$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()) {
+ $scope.oldInterface.Nameservers.toString()) {
promises.push(setNameservers());
}
@@ -100,31 +100,28 @@
for (var i in $scope.interface.ipv4.values) {
if (!APIUtils.validIPV4IP(
$scope.interface.ipv4.values[i].Address)) {
- $scope.set_network_error =
- $scope.interface.ipv4.values[i].Address +
+ $scope.setNetworkError = $scope.interface.ipv4.values[i].Address +
' invalid IP parameter';
$scope.loading = false;
return;
}
if (!APIUtils.validIPV4IP(
$scope.interface.ipv4.values[i].Gateway)) {
- $scope.set_network_error =
- $scope.interface.ipv4.values[i].Address +
+ $scope.setNetworkError = $scope.interface.ipv4.values[i].Address +
' invalid gateway parameter';
$scope.loading = false;
return;
}
// The netmask prefix length will be undefined if outside range
if (!$scope.interface.ipv4.values[i].PrefixLength) {
- $scope.set_network_error =
- $scope.interface.ipv4.values[i].Address +
+ $scope.setNetworkError = $scope.interface.ipv4.values[i].Address +
' invalid Prefix Length parameter';
$scope.loading = false;
return;
}
- if ($scope.interface.ipv4.values[i].update_address ||
- $scope.interface.ipv4.values[i].update_gateway ||
- $scope.interface.ipv4.values[i].update_prefix) {
+ if ($scope.interface.ipv4.values[i].updateAddress ||
+ $scope.interface.ipv4.values[i].updateGateway ||
+ $scope.interface.ipv4.values[i].updatePrefix) {
// If IPV4 has an id it means it already exists in the back end,
// and in order to update it is required to remove previous IPV4
// address and add new one. See openbmc/openbmc/issues/2163.
@@ -141,8 +138,8 @@
if (promises.length) {
$q.all(promises).finally(function() {
$scope.loading = false;
- if (!$scope.set_network_error) {
- $scope.set_network_success = true;
+ if (!$scope.setNetworkError) {
+ $scope.setNetworkSuccess = true;
// Since an IPV4 interface (e.g. IP address, gateway, or netmask)
// edit is a delete then an add and the GUI can't calculate the
// interface id (e.g. 5c083707) beforehand and it is not returned
@@ -150,7 +147,7 @@
// which makes a 2nd REST call.
// Do this for all network changes due to the possibility of a set
// network failing even though it returned success, openbmc#1641,
- // and to update dataService and old_interface to know which
+ // and to update dataService and oldInterface to know which
// data has changed if the user continues to edit network
// settings.
// TODO: The reload is not ideal. Revisit this.
@@ -172,17 +169,17 @@
function(data) {},
function(error) {
console.log(JSON.stringify(error));
- $scope.set_network_error = 'MAC Address';
+ $scope.setNetworkError = 'MAC Address';
});
}
function setDefaultGateway() {
- return APIUtils.setDefaultGateway($scope.defaultgateway)
+ return APIUtils.setDefaultGateway($scope.defaultGateway)
.then(
function(data) {},
function(error) {
console.log(JSON.stringify(error));
- $scope.set_network_error = 'Default Gateway';
+ $scope.setNetworkError = 'Default Gateway';
});
}
@@ -192,7 +189,7 @@
function(data) {},
function(error) {
console.log(JSON.stringify(error));
- $scope.set_network_error = 'Hostname';
+ $scope.setNetworkError = 'Hostname';
});
}
@@ -204,7 +201,7 @@
function(data) {},
function(error) {
console.log(JSON.stringify(error));
- $scope.set_network_error = 'DHCP';
+ $scope.setNetworkError = 'DHCP';
});
}
@@ -221,18 +218,18 @@
function(data) {},
function(error) {
console.log(JSON.stringify(error));
- $scope.set_network_error = 'DNS Servers';
+ $scope.setNetworkError = 'DNS Servers';
});
}
function removeIPV4s() {
- return $scope.IPV4s_to_delete.map(function(ipv4) {
+ return $scope.ipv4sToDelete.map(function(ipv4) {
return APIUtils.deleteIPV4($scope.selectedInterface, ipv4.id)
.then(
function(data) {},
function(error) {
console.log(JSON.stringify(error));
- $scope.set_network_error = ipv4.Address;
+ $scope.setNetworkError = ipv4.Address;
})
});
}
@@ -248,7 +245,7 @@
function(data) {},
function(error) {
console.log(JSON.stringify(error));
- $scope.set_network_error =
+ $scope.setNetworkError =
$scope.interface.ipv4.values[index].Address;
})
}
@@ -272,13 +269,13 @@
function(data) {},
function(error) {
console.log(JSON.stringify(error));
- $scope.set_network_error =
+ $scope.setNetworkError =
$scope.interface.ipv4.values[index].Address;
});
},
function(error) {
console.log(JSON.stringify(error));
- $scope.set_network_error =
+ $scope.setNetworkError =
$scope.interface.ipv4.values[index].Address;
});
}
@@ -292,7 +289,7 @@
dataService.setNetworkInfo(data);
$scope.network = data.formatted_data;
$scope.hostname = data.hostname;
- $scope.defaultgateway = data.defaultgateway;
+ $scope.defaultGateway = data.defaultgateway;
if ($scope.network.interface_ids.length) {
// Use the first network interface if the user hasn't chosen one
if (!$scope.selectedInterface ||
@@ -303,14 +300,14 @@
$scope.network.interfaces[$scope.selectedInterface];
// Copy the interface so we know later if changes were made to the
// page
- $scope.old_interface = JSON.parse(JSON.stringify($scope.interface));
+ $scope.oldInterface = JSON.parse(JSON.stringify($scope.interface));
}
// Add id values and update flags to corresponding IPV4 objects
for (var i = 0; i < $scope.interface.ipv4.values.length; i++) {
$scope.interface.ipv4.values[i].id = $scope.interface.ipv4.ids[i];
- $scope.interface.ipv4.values[i].update_address = false;
- $scope.interface.ipv4.values[i].update_gateway = false;
- $scope.interface.ipv4.values[i].update_prefix = false;
+ $scope.interface.ipv4.values[i].updateAddress = false;
+ $scope.interface.ipv4.values[i].updateGateway = false;
+ $scope.interface.ipv4.values[i].updatePrefix = false;
}
});
}