summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGunnar Mills <gmills@us.ibm.com>2018-04-12 16:12:03 -0500
committerGunnar Mills <gmills@us.ibm.com>2018-05-25 09:50:55 -0500
commit7ddc7274a98f518772efa96b93e9b331d7a61117 (patch)
tree8b0fc1a66c82fa0e3ab08883200b086f77997e4b
parent7d6e62998fac2d905d17c1dbececb403a9ab8bdb (diff)
downloadphosphor-webui-7ddc7274a98f518772efa96b93e9b331d7a61117.tar.gz
phosphor-webui-7ddc7274a98f518772efa96b93e9b331d7a61117.zip
Set MAC address on "Save Settings"
Make a REST call to set the MAC address when the "Save Settings" button is pressed. Tested: Verified the MAC Address is set. Change-Id: I39f6d4688842b3453fd219795d07f819ba4ba481 Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
-rw-r--r--app/common/services/api-utils.js17
-rw-r--r--app/common/styles/elements/index.scss1
-rw-r--r--app/common/styles/elements/success.scss7
-rw-r--r--app/configuration/controllers/network-controller.html8
-rw-r--r--app/configuration/controllers/network-controller.js20
-rw-r--r--app/configuration/styles/network.scss6
6 files changed, 55 insertions, 4 deletions
diff --git a/app/common/services/api-utils.js b/app/common/services/api-utils.js
index fec8572..5e0cd3c 100644
--- a/app/common/services/api-utils.js
+++ b/app/common/services/api-utils.js
@@ -183,6 +183,23 @@ window.angular && (function(angular) {
});
return deferred.promise;
},
+ setMACAddress: function(interface_name, mac_address) {
+ return $http({
+ method: 'PUT',
+ url: DataService.getHost() +
+ '/xyz/openbmc_project/network/' + interface_name +
+ '/attr/MACAddress',
+ headers: {
+ 'Accept': 'application/json',
+ 'Content-Type': 'application/json'
+ },
+ withCredentials: true,
+ data: JSON.stringify({'data': mac_address})
+ })
+ .then(function(response) {
+ return response.data;
+ });
+ },
getLEDState: function() {
var deferred = $q.defer();
$http({
diff --git a/app/common/styles/elements/index.scss b/app/common/styles/elements/index.scss
index d431ef8..9a6fe55 100644
--- a/app/common/styles/elements/index.scss
+++ b/app/common/styles/elements/index.scss
@@ -12,3 +12,4 @@
@import "modals";
@import "quicklinks";
@import "errors";
+@import "success";
diff --git a/app/common/styles/elements/success.scss b/app/common/styles/elements/success.scss
new file mode 100644
index 0000000..defdb16
--- /dev/null
+++ b/app/common/styles/elements/success.scss
@@ -0,0 +1,7 @@
+.success-msg {
+ color: $primebtn__bg;
+ padding: 1em;
+ font-size: 1em;
+ font-family: "Courier New", Helvetica, Arial, sans-serif;
+ font-weight: 500;
+}
diff --git a/app/configuration/controllers/network-controller.html b/app/configuration/controllers/network-controller.html
index caa2913..6c494d0 100644
--- a/app/configuration/controllers/network-controller.html
+++ b/app/configuration/controllers/network-controller.html
@@ -81,9 +81,11 @@
</div>
</fieldset>
<div class="network-config__submit-wrapper">
- <button class="btn-primary inline">Save settings</button>
- <button class="btn-secondary inline">Cancel</button>
+ <button type="button" class="btn-primary inline" ng-click="setNetworkSettings()">Save settings</button>
+ <button type="button" class="btn-secondary inline">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>
</section>
</form>
-</div> \ No newline at end of file
+</div>
diff --git a/app/configuration/controllers/network-controller.js b/app/configuration/controllers/network-controller.js
index e764de8..b3d33f9 100644
--- a/app/configuration/controllers/network-controller.js
+++ b/app/configuration/controllers/network-controller.js
@@ -17,12 +17,32 @@ window.angular && (function(angular) {
$scope.interface = {};
$scope.networkDevice = false;
$scope.hostname = '';
+ $scope.set_network_error = '';
+ $scope.set_network_success = false;
+ $scope.selectedInterface = '';
$scope.selectInterface = function(interfaceId) {
$scope.interface = $scope.network.interfaces[interfaceId];
$scope.selectedInterface = interfaceId;
$scope.networkDevice = false;
};
+ $scope.setNetworkSettings = function() {
+ $scope.set_network_error = '';
+ $scope.set_network_success = false;
+ // TODO openbmc/openbmc#3165: check if the network settings
+ // changed before setting
+ APIUtils
+ .setMACAddress(
+ $scope.selectedInterface, $scope.interface.MACAddress)
+ .then(
+ function(data) {
+ $scope.set_network_success = true;
+ },
+ function(error) {
+ console.log(error);
+ $scope.set_network_error = 'MAC Address';
+ });
+ };
APIUtils.getNetworkInfo().then(function(data) {
$scope.network = data.formatted_data;
$scope.hostname = data.hostname;
diff --git a/app/configuration/styles/network.scss b/app/configuration/styles/network.scss
index b4bd72d..26653fd 100644
--- a/app/configuration/styles/network.scss
+++ b/app/configuration/styles/network.scss
@@ -43,4 +43,8 @@
margin: .5em;
}
}
-} \ No newline at end of file
+ .set_network_error
+ {
+ margin-left: 3em;
+ }
+}
OpenPOWER on IntegriCloud