diff --git a/app/kubernetes/views/applications/create/createApplication.html b/app/kubernetes/views/applications/create/createApplication.html index 38bb3d04f..61b16176c 100644 --- a/app/kubernetes/views/applications/create/createApplication.html +++ b/app/kubernetes/views/applications/create/createApplication.html @@ -1353,7 +1353,7 @@ class="btn btn-primary" ng-model="publishedPort.Protocol" uib-btn-radio="'TCP'" - ng-change="ctrl.onChangePortMappingContainerPort()" + ng-change="ctrl.onChangePortProtocol($index)" ng-disabled="ctrl.isProtocolOptionDisabled($index, 'TCP')" >TCP @@ -1361,7 +1361,7 @@ class="btn btn-primary" ng-model="publishedPort.Protocol" uib-btn-radio="'UDP'" - ng-change="ctrl.onChangePortMappingContainerPort()" + ng-change="ctrl.onChangePortProtocol($index)" ng-disabled="ctrl.isProtocolOptionDisabled($index, 'UDP')" >UDP diff --git a/app/kubernetes/views/applications/create/createApplicationController.js b/app/kubernetes/views/applications/create/createApplicationController.js index 1ae918070..e6347e597 100644 --- a/app/kubernetes/views/applications/create/createApplicationController.js +++ b/app/kubernetes/views/applications/create/createApplicationController.js @@ -303,6 +303,9 @@ class KubernetesCreateApplicationController { const ingresses = this.filteredIngresses; p.IngressName = ingresses && ingresses.length ? ingresses[0].Name : undefined; p.IngressHost = ingresses && ingresses.length ? ingresses[0].Host : undefined; + if (this.formValues.PublishedPorts.length) { + p.Protocol = this.formValues.PublishedPorts[0].Protocol; + } this.formValues.PublishedPorts.push(p); } @@ -335,6 +338,7 @@ class KubernetesCreateApplicationController { this.onChangePortMappingNodePort(); this.onChangePortMappingIngressRoute(); this.onChangePortMappingLoadBalancer(); + this.onChangePortProtocol(); } onChangePortMappingContainerPort() { @@ -403,6 +407,16 @@ class KubernetesCreateApplicationController { state.hasDuplicates = false; } } + + onChangePortProtocol(index) { + this.onChangePortMappingContainerPort(); + if (this.formValues.PublishingType === KubernetesApplicationPublishingTypes.LOAD_BALANCER) { + const newPorts = _.filter(this.formValues.PublishedPorts, { IsNew: true }); + _.forEach(newPorts, (port) => { + port.Protocol = index ? this.formValues.PublishedPorts[index].Protocol : newPorts[0].Protocol; + }); + } + } /* #endregion */ /* #region STATE VALIDATION FUNCTIONS */ @@ -561,6 +575,10 @@ class KubernetesCreateApplicationController { return this.state.isEdit && !this.formValues.Placements[index].IsNew; } + isNewAndNotFirst(index) { + return !this.state.isEdit && index !== 0; + } + showPlacementPolicySection() { const placements = _.filter(this.formValues.Placements, { NeedsDeletion: false }); return placements.length !== 0; @@ -600,8 +618,17 @@ class KubernetesCreateApplicationController { return this.state.isEdit && this.formValues.PublishedPorts.length > 0 && ports.length > 0; } + isEditLBWithPorts() { + return this.formValues.PublishingType === KubernetesApplicationPublishingTypes.LOAD_BALANCER && _.filter(this.formValues.PublishedPorts, { IsNew: false }).length; + } + isProtocolOptionDisabled(index, protocol) { - return this.disableLoadBalancerEdit() || (this.isEditAndNotNewPublishedPort(index) && this.formValues.PublishedPorts[index].Protocol !== protocol); + return ( + this.disableLoadBalancerEdit() || + (this.isEditAndNotNewPublishedPort(index) && this.formValues.PublishedPorts[index].Protocol !== protocol) || + (this.isEditLBWithPorts() && this.formValues.PublishedPorts[index].Protocol !== protocol) || + (this.isNewAndNotFirst(index) && this.formValues.PublishedPorts[index].Protocol !== protocol) + ); } /* #endregion */