subnet selection will not be changed when a new option is added

Change-Id: Ie098ef8bf5a4a92ec7d7de20fee2ee2643a594c9
This commit is contained in:
chi zhang 2014-09-15 12:08:38 -07:00 committed by Chi Zhang
parent bb3c7ca8df
commit f684fc0456
2 changed files with 54 additions and 52 deletions

View File

@ -210,49 +210,48 @@
</tbody>
</table>
</div>
<div>
<script type="text/ng-template" id="addSubnetModal.html">
<div class="modal-header">
<h3 class="modal-title" >Subnetwork </h3>
</div>
<div class= "modal-body" >
<alert ng-repeat="alert in alerts" type="danger" close="closeAlert()" >
<span ng-if="alert.message">
{{alert.message}}
</span>
<span ng-if="!alert.message">
Unknown error
</span>
</alert>
<table class="table table-hover nowrap">
<thead>
<tr>
<th>Subnet</th >
<th> Actions </th>
</tr >
</thead>
<tbody>
<tr ng-repeat="sub in subnetworks">
<td>
<input type="text" ng-model="sub.subnet" ng-class="{'red-border': !sub.valid}" placeholder="Subnet" ng-change="subnet_change($index,sub.subnet)" required/ >
</td>
<td>
<span class="action" ng-click="addSubnetwork()">
<i class="fa fa-plus-circle bigger-140 blue"></i>
</span>
<span ng-show="subnetworks.length > 1" class="action" ng-click="removeSubnetwork($index)">
<i class="fa fa-minus-circle bigger-140 blue"></i>
</span>
</td>
</tr>
</tbody>
</table>
</div >
<div class = "modal-footer" >
<button class = "btn btn-primary" ng-disabled = "!subnetAllValid" ng-click = "ok()" > OK </button>
<button class="btn btn-grey" ng-click="cancel()">Cancel</button>
</div>
</script>
</div>
</div>
<div>
<script type="text/ng-template" id="addSubnetModal.html">
<div class="modal-header">
<h3 class="modal-title" >Subnetwork </h3>
</div>
<div class= "modal-body" >
<alert ng-repeat="alert in alerts" type="danger" close="closeAlert()" >
{{alert.message}}
</alert>
<table class="table table-hover nowrap">
<thead>
<tr>
<th>Subnet</th >
<th> Actions </th>
</tr >
</thead>
<tbody>
<tr ng-repeat="sub in subnetworks">
<td>
<input type="text" ng-model="sub.subnet" ng-class="{'red-border': !sub.valid}" placeholder="Subnet" ng-change="subnet_change($index,sub.subnet)" required/ >
</td>
<td>
<span class="action" ng-click="addSubnetwork()">
<i class="fa fa-plus-circle bigger-140 blue"></i>
</span>
<span ng-show="subnetworks.length > 1" class="action" ng-click="removeSubnetwork($index)">
<i class="fa fa-minus-circle bigger-140 blue"></i>
</span>
</td>
</tr>
</tbody>
</table>
</div >
<div class = "modal-footer" >
<button class = "btn btn-primary" ng-disabled = "!subnetAllValid" ng-click = "ok()" > OK </button>
<button class="btn btn-grey" ng-click="cancel()">Cancel</button>
</div>
</script>
</div>

View File

@ -333,9 +333,9 @@ angular.module('compass.wizard', [
};
$scope.ifPreSelect = function(server) {
if(server.clusters) {
if (server.clusters) {
angular.forEach(server.clusters, function(svCluster) {
if(svCluster.id == cluster.id) {
if (svCluster.id == cluster.id) {
server.selected = true;
}
})
@ -614,7 +614,6 @@ angular.module('compass.wizard', [
alert("This interface already exists. Please try another one");
}
})
if (!isExist) {
$scope.interfaces[newInterface.name] = {
"subnet_id": parseInt(newInterface.subnet_id),
@ -745,7 +744,10 @@ angular.module('compass.wizard', [
}
});
modalInstance.result.then(function(subnets) {
$scope.subnetworks = subnets;
$scope.subnetworks = [];
angular.forEach(subnets, function(subnet) {
$scope.subnetworks.push(subnet);
});
}, function() {
console.log("modal dismissed")
})
@ -1530,7 +1532,7 @@ var wizardModalInstanceCtrl = function($scope, $modalInstance, warning) {
};
var addSubnetModalInstanceCtrl = function($scope, $modalInstance, $q, subnets, dataService, $filter) {
$scope.subnetworks = subnets;
$scope.subnetworks = angular.copy(subnets);
$scope.subnetAllValid = true;
angular.forEach($scope.subnetworks, function(subnet) {
@ -1585,7 +1587,9 @@ var addSubnetModalInstanceCtrl = function($scope, $modalInstance, $q, subnets, d
});
$q.all(promises).then(function() {
$scope.subnetworks = subnetworks;
for(var i = 0; i < subnets.length && i < $scope.subnetworks.length; i++) {
$scope.subnetworks[i].$$hashKey = subnets[i].$$hashKey;
}
$modalInstance.close($scope.subnetworks);
}, function(response) {
console.log("promises error", response);
@ -1601,7 +1605,7 @@ var addSubnetModalInstanceCtrl = function($scope, $modalInstance, $q, subnets, d
$scope.subnetworks = $filter('filter')($scope.subnetworks, {
valid: true
}, true);
$modalInstance.close($scope.subnetworks);
$modalInstance.dismiss('cancel');
};
@ -1614,7 +1618,6 @@ var addSubnetModalInstanceCtrl = function($scope, $modalInstance, $q, subnets, d
valid: false
});
allValid();
console.log($scope.subnetworks);
};
$scope.removeSubnetwork = function(index) {