diff options
| author | Gunnar Mills <gmills@us.ibm.com> | 2018-09-18 15:49:33 -0500 |
|---|---|---|
| committer | Gunnar Mills <gmills@us.ibm.com> | 2018-11-02 14:02:56 +0000 |
| commit | 8751084c3a7430509a3a3c9e5c415e963f7922e4 (patch) | |
| tree | e7819ef20518dd75785cf644aaa20315490ca00e /app/configuration | |
| parent | 31461a1d9a5db4762e1616792cf8a718a99bf488 (diff) | |
| download | phosphor-webui-8751084c3a7430509a3a3c9e5c415e963f7922e4.tar.gz phosphor-webui-8751084c3a7430509a3a3c9e5c415e963f7922e4.zip | |
Only update SNMP fields if changed
Use ng-change to determine if the SNMP fields, Address and Port,
have changed and should be updated.
Tested: Only see the rest calls when the fields have changed.
Change-Id: I324c9c422a8b6dfb8816925167953e16099f8044
Signed-off-by: Gunnar Mills <gmills@us.ibm.com>
Diffstat (limited to 'app/configuration')
| -rw-r--r-- | app/configuration/controllers/snmp-controller.html | 4 | ||||
| -rw-r--r-- | app/configuration/controllers/snmp-controller.js | 17 |
2 files changed, 13 insertions, 8 deletions
diff --git a/app/configuration/controllers/snmp-controller.html b/app/configuration/controllers/snmp-controller.html index 3fd9aa3..f4b7279 100644 --- a/app/configuration/controllers/snmp-controller.html +++ b/app/configuration/controllers/snmp-controller.html @@ -12,11 +12,11 @@ <div class="snmp__managers" ng-repeat="manager in managers track by $index"> <div class="snmp__manager-field"> <label>SNMP Manager Server</label> - <input class="inline" id="snmp-manager{{$index+1}}-address" type="text" ng-model="manager.address" ng-blur="managers[$index].address = manager.address"/> + <input class="inline" id="snmp-manager{{$index+1}}-address" ng-change="manager.update_address = true" type="text" ng-model="manager.address" ng-blur="managers[$index].address = manager.address"/> </div> <div class="snmp__manager-field"> <label>Port</label> - <input class="inline" id="snmp-manager{{$index+1}}-port" type="text" ng-model="manager.port" ng-blur="managers[$index].port = manager.port"/> + <input class="inline" id="snmp-manager{{$index+1}}-port" type="text" ng-change="manager.update_port = true" ng-model="manager.port" ng-blur="managers[$index].port = manager.port"/> </div> <button class="snmp__manager-remove" ng-click="removeSNMPManager($index)">Remove</button> </div> diff --git a/app/configuration/controllers/snmp-controller.js b/app/configuration/controllers/snmp-controller.js index 782ee1c..a2f5e2b 100644 --- a/app/configuration/controllers/snmp-controller.js +++ b/app/configuration/controllers/snmp-controller.js @@ -26,7 +26,9 @@ window.angular && (function(angular) { $scope.managers.push({ path: key, port: data.data[key].Port, - address: data.data[key].Address + update_port: false, + address: data.data[key].Address, + update_address: false }) } }, @@ -85,11 +87,14 @@ window.angular && (function(angular) { promises.push(addManager( $scope.managers[i].address, $scope.managers[i].port)); } else { - // TODO: Check if we actually need to update the existing managers - promises.push(setManagerAddress( - $scope.managers[i].path, $scope.managers[i].address)); - promises.push(setManagerPort( - $scope.managers[i].path, $scope.managers[i].port)); + if ($scope.managers[i].update_address) { + promises.push(setManagerAddress( + $scope.managers[i].path, $scope.managers[i].address)); + } + if ($scope.managers[i].update_port) { + promises.push(setManagerPort( + $scope.managers[i].path, $scope.managers[i].port)); + } } } |

