Merge "Fix subnet_id null bug for newly added subnets"

This commit is contained in:
Jenkins 2014-09-27 04:42:59 +00:00 committed by Gerrit Code Review
commit 1e7b4d7a77
3 changed files with 9 additions and 5 deletions

View File

@ -124,6 +124,9 @@ select {
border-radius: 7px;
height: 33px;
}
select option[value=""], select.form-control option[value=""] {
padding: 3px 4px;
}
.opacity-zero {
opacity: 0;
}
@ -1041,4 +1044,4 @@ circle[depth='4'] {
h4.widget-title:hover {
color: #2a6496;
text-decoration: underline;
}
}

View File

@ -813,7 +813,7 @@ compassAppDev.run(function($httpBackend, settings, $http) {
console.log(method, url, data);
var subnetConfig = JSON.parse(data);
subnetConfig.subnet_id = Math.floor((Math.random() * 100) + 1);
subnetConfig.id = Math.floor((Math.random() * 100) + 1);
console.log(subnetConfig);
return [200, subnetConfig, {}];

View File

@ -1756,7 +1756,7 @@ var addSubnetModalInstanceCtrl = function($scope, $modalInstance, $q, subnets, d
};
$scope.ok = function() {
var subnetworks = [];
var newsubnetworks = [];
var promises = [];
angular.forEach($scope.subnetworks, function(subnet) {
var requestData = {
@ -1765,7 +1765,7 @@ var addSubnetModalInstanceCtrl = function($scope, $modalInstance, $q, subnets, d
if (subnet.id === undefined) {
// post subnetworks
var updateSubnetConfig = dataService.postSubnetConfig(requestData).then(function(subnetData) {
subnetworks.push(subnetData.data);
newsubnetworks.push(subnetData.data);
}, function(response) {
return $q.reject(response);
});
@ -1773,7 +1773,7 @@ var addSubnetModalInstanceCtrl = function($scope, $modalInstance, $q, subnets, d
} else {
// put subnetworks
var updateSubnetConfig = dataService.putSubnetConfig(subnet.id, requestData).then(function(subnetData) {
subnetworks.push(subnetData.data);
newsubnetworks.push(subnetData.data);
}, function(response) {
return $q.reject(response);
});
@ -1782,6 +1782,7 @@ var addSubnetModalInstanceCtrl = function($scope, $modalInstance, $q, subnets, d
});
$q.all(promises).then(function() {
$scope.subnetworks = newsubnetworks;
for (var i = 0; i < subnets.length && i < $scope.subnetworks.length; i++) {
$scope.subnetworks[i].$$hashKey = subnets[i].$$hashKey;
}