From de02f3b331af08f59b99e51a38525424ba52edb5 Mon Sep 17 00:00:00 2001 From: Xinni Ge Date: Tue, 5 Dec 2017 10:16:05 +0900 Subject: [PATCH] Fix nova server networks config options Enhance the user input modal of nova server networks tab. 1. Update property value options when change property type. 2. Delete error disabling when one config element is deleted. 3. Fix typo. Change-Id: I69f641a1ded29372b330439ca1f2354509b70e6b --- .../resources/os__nova__server/os__nova__server.html | 2 +- .../js/resources/os__nova__server/os__nova__server.js | 10 +++++++--- .../os__nova__server/os__nova__server.spec.js | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__nova__server/os__nova__server.html b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__nova__server/os__nova__server.html index 0a883520..f3b4e5d8 100644 --- a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__nova__server/os__nova__server.html +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__nova__server/os__nova__server.html @@ -228,7 +228,7 @@ - + network subnet port diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__nova__server/os__nova__server.js b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__nova__server/os__nova__server.js index 4841b8f9..9a831e70 100644 --- a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__nova__server/os__nova__server.js +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__nova__server/os__nova__server.js @@ -119,7 +119,7 @@ this.instance.block_device_mapping_v2 = []; } if (typeof this.instance.networks === 'undefined'){ - this.instance.networks = [{}]; + this.instance.networks = []; } this.disable = { @@ -427,7 +427,7 @@ } return $scope.options.subnets.concat(resource_subnet); } - return $scope.options.networks; + return $scope.options.subnets; } $scope.get_floatingips_options = function(){ if ('networks.floating_ip' in $scope.connected_options){ @@ -561,8 +561,12 @@ for (var i = index; i < this.instance.networks.length; i=i+1){ $scope.how2config_networks[i] = $scope.how2config_networks[i+1]; } + delete $scope.how2config_networks[this.instance.networks.length]; this.instance.networks.splice(index, 1); - + for (var i = index; i < this.instance.networks.length; i=i+1){ + this.disable.networks[i] = this.disable.networks[i+1]; + } + delete this.disable.networks[this.instance.networks.length]; } this.add_networks = function(){ this.instance.networks.push({}) diff --git a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__nova__server/os__nova__server.spec.js b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__nova__server/os__nova__server.spec.js index 540568d9..d3e1dd1e 100644 --- a/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__nova__server/os__nova__server.spec.js +++ b/heat_dashboard/static/dashboard/project/heat_dashboard/template_generator/js/resources/os__nova__server/os__nova__server.spec.js @@ -272,7 +272,7 @@ var $ctrl = $isolateScope.$ctrl; $ctrl.add_networks(); - expect($scope.resource.networks.length).toEqual(2); + expect($scope.resource.networks.length).toEqual(1); }); it('networks should be successfully deleted', function() {