diff --git a/app/containers/new/view.js b/app/containers/new/view.js
index 07b09096d..daf9bcb7b 100644
--- a/app/containers/new/view.js
+++ b/app/containers/new/view.js
@@ -1,7 +1,8 @@
import Ember from 'ember';
import { addAction } from 'ui/utils/add-view-action';
+import SelectTab from 'ui/mixins/select-tab';
-export default Ember.View.extend({
+export default Ember.View.extend(SelectTab, {
actions: {
addEnvironment: addAction('addEnvironment', '.environment-name'),
addPort: addAction('addPort', '.port-public'),
@@ -13,14 +14,6 @@ export default Ember.View.extend({
addDevice: addAction('addDevice', '.device-host'),
addLabel: addAction('addLabel', '.label-key'),
addSchedulingRule: addAction('addSchedulingRule', '.schedule-rule'),
-
- selectTab: function(name) {
- this.set('context.tab',name);
- this.$('.tab').removeClass('active');
- this.$('.tab[data-section="'+name+'"]').addClass('active');
- this.$('.section').addClass('hide');
- this.$('.section[data-section="'+name+'"]').removeClass('hide');
- }
},
didInsertElement: function() {
@@ -109,7 +102,7 @@ export default Ember.View.extend({
this.$('.select-cap-drop').multiselect(opts);
},
- priviligedDidChange: function() {
+ privilegedDidChange: function() {
var add = this.$('.select-cap-add');
var drop = this.$('.select-cap-drop');
if ( add && drop )
diff --git a/app/environments/new/view.js b/app/environments/new/view.js
index 207a7d39c..30ab35ce8 100644
--- a/app/environments/new/view.js
+++ b/app/environments/new/view.js
@@ -1,20 +1,13 @@
import Ember from 'ember';
import { addAction } from 'ui/utils/add-view-action';
+import SelectTab from 'ui/mixins/select-tab';
-export default Ember.View.extend({
+export default Ember.View.extend(SelectTab, {
actions: {
addHost: addAction('addHost', '.lb-host'),
addTargetContainer: addAction('addTargetContainer', '.lb-target'),
addTargetIp: addAction('addTargetIp', '.lb-target'),
addListener: addAction('addListener', '.lb-listener-source-port'),
-
- selectTab: function(name) {
- this.set('context.tab',name);
- this.$('.tab').removeClass('active');
- this.$('.tab[data-section="'+name+'"]').addClass('active');
- this.$('.section').addClass('hide');
- this.$('.section[data-section="'+name+'"]').removeClass('hide');
- }
},
didInsertElement: function() {
diff --git a/app/loadbalancerconfig/controller.js b/app/loadbalancerconfig/controller.js
index fa8aa5a86..1f5fbecf3 100644
--- a/app/loadbalancerconfig/controller.js
+++ b/app/loadbalancerconfig/controller.js
@@ -29,6 +29,12 @@ var LoadBalancerConfigController = Cattle.TransitioningResourceController.extend
sourceContent: this.get('loadBalancers'),
});
}.property('loadBalancers'),
+
+ unremovedListeners: function() {
+ return UnremovedArrayProxy.create({
+ sourceContent: this.get('listeners'),
+ });
+ }.property('listeners'),
});
LoadBalancerConfigController.reopenClass({
diff --git a/app/loadbalancerconfig/edit/controller.js b/app/loadbalancerconfig/edit/controller.js
index 71a46dd71..0999e3d83 100644
--- a/app/loadbalancerconfig/edit/controller.js
+++ b/app/loadbalancerconfig/edit/controller.js
@@ -1,8 +1,50 @@
import Ember from 'ember';
import Cattle from 'ui/utils/cattle';
+import EditLoadBalancerConfig from 'ui/mixins/edit-loadbalancerconfig';
-export default Ember.ObjectController.extend(Cattle.NewOrEditMixin, {
+export default Ember.ObjectController.extend(Cattle.NewOrEditMixin, EditLoadBalancerConfig, {
editing: true,
+ primaryResource: Ember.computed.alias('model.config'),
+ queryParams: ['tab'],
+ tab: 'listeners',
+
+ initFields: function() {
+ this._super();
+ this.initListeners();
+ this.initStickiness();
+ this.initHealthCheck();
+ },
+
+ didSave: function() {
+ var orig = this.get('listeners')||[];
+ var neu = this.get('listenersArray');
+
+ var promises = [];
+ orig.forEach((listener) => {
+ // Delete removed
+ if( neu.indexOf(listener) === -1 )
+ {
+ promises.push(listener.delete());
+ }
+ });
+
+ neu.forEach((listener) => {
+ if ( orig.indexOf(listener) === -1 )
+ {
+ promises.push(listener.save());
+ }
+ });
+
+ return Ember.RSVP.all(promises).then(() => {
+ var ids = neu.filter((listener) => {
+ return neu.indexOf(listener) >= 0;
+ }).map((listener) => {
+ return listener.get('id');
+ });
+
+ return this.get('config').doAction('setlisteners',{loadBalancerListenerIds: ids});
+ });
+ },
doneSaving: function() {
this.send('goToPrevious');
diff --git a/app/loadbalancerconfig/edit/route.js b/app/loadbalancerconfig/edit/route.js
index 3c99c8aff..8c5446a87 100644
--- a/app/loadbalancerconfig/edit/route.js
+++ b/app/loadbalancerconfig/edit/route.js
@@ -2,12 +2,57 @@ import Ember from 'ember';
export default Ember.Route.extend({
model: function() {
- return this.modelFor('loadbalancerconfig');
+ var store = this.get('store');
+ var orig = this.modelFor('loadbalancerconfig');
+ var config = orig.clone();
+ var listeners = (orig.get('listeners')||[]).filter((listener) => {
+ return ['removed','purging','purged'].indexOf(listener.get('state')) === -1;
+ });
+
+ var healthCheck = config.get('healthCheck');
+ if ( !healthCheck )
+ {
+ healthCheck = store.createRecord({
+ type: 'loadBalancerHealthCheck',
+ interval: 2000,
+ responseTimeout: 2000,
+ healthyThreshold: 2,
+ unhealthyThreshold: 3,
+ });
+
+ config.set('healthCheck', healthCheck);
+ }
+
+ var appCookie = config.get('appCookieStickinessPolicy');
+ if ( !appCookie )
+ {
+ appCookie = store.createRecord({
+ type: 'loadBalancerAppCookieStickinessPolicy',
+ mode: 'path_parameters',
+ requestLearn: true,
+ timeout: 3600000,
+ });
+ }
+
+ var lbCookie = config.get('lbCookieStickinessPolicy');
+ if ( !appCookie )
+ {
+ lbCookie = store.createRecord({
+ type: 'loadBalancerCookieStickinessPolicy'
+ });
+ }
+
+ return {
+ listeners: listeners,
+ config: config,
+ healthCheck: healthCheck,
+ appCookie: appCookie,
+ lbCookie: lbCookie,
+ };
},
setupController: function(controller, model) {
- controller.set('originalModel',model);
- controller.set('model', model.clone());
+ controller.set('model', model);
controller.initFields();
},
@@ -15,6 +60,13 @@ export default Ember.Route.extend({
this.render('loadbalancerconfig/edit', {into: 'application', outlet: 'overlay'});
},
+ resetController: function (controller, isExiting/*, transition*/) {
+ if (isExiting)
+ {
+ controller.set('tab', 'listeners');
+ }
+ },
+
actions: {
cancel: function() {
this.goToPrevious();
diff --git a/app/loadbalancerconfig/edit/template.hbs b/app/loadbalancerconfig/edit/template.hbs
index 71e8c0719..d3fb3688f 100644
--- a/app/loadbalancerconfig/edit/template.hbs
+++ b/app/loadbalancerconfig/edit/template.hbs
@@ -7,7 +7,7 @@
- {{input id="name" type="text" value=name classNames="form-control" placeholder="e.g. Website"}}
+ {{input id="name" type="text" value=primaryResource.name classNames="form-control" placeholder="e.g. Website"}}
@@ -16,9 +16,11 @@
- {{textarea id="description" value=description classNames="form-control no-resize" rows="5" placeholder="e.g. Balancer for mycompany.com"}}
+ {{textarea id="description" value=primaryResource.description classNames="form-control no-resize" rows="5" placeholder="e.g. Balancer for mycompany.com"}}
+{{partial "loadbalancer/edit-config"}}
+
{{partial "save-cancel"}}
diff --git a/app/loadbalancerconfig/edit/view.js b/app/loadbalancerconfig/edit/view.js
index ab8f022ee..66fca9917 100644
--- a/app/loadbalancerconfig/edit/view.js
+++ b/app/loadbalancerconfig/edit/view.js
@@ -1,7 +1,11 @@
import Overlay from "ui/overlay/view";
+import SelectTab from 'ui/mixins/select-tab';
+import { addAction } from 'ui/utils/add-view-action';
-export default Overlay.extend({
+export default Overlay.extend(SelectTab, {
actions: {
+ addListener: addAction('addListener', '.lb-listener-source-port'),
+
overlayClose: function() {
this.get('controller').send('cancel');
},
@@ -9,5 +13,10 @@ export default Overlay.extend({
overlayEnter: function() {
this.get('controller').send('save');
},
- }
+ },
+
+ didInsertElement: function() {
+ this.send('selectTab',this.get('context.tab'));
+ },
+
});
diff --git a/app/loadbalancerconfigs/new/view.js b/app/loadbalancerconfigs/new/view.js
index be9fb429e..831d8507b 100644
--- a/app/loadbalancerconfigs/new/view.js
+++ b/app/loadbalancerconfigs/new/view.js
@@ -1,20 +1,13 @@
import Ember from 'ember';
import { addAction } from 'ui/utils/add-view-action';
+import SelectTab from 'ui/mixins/select-tab';
-export default Ember.View.extend({
+export default Ember.View.extend(SelectTab, {
actions: {
addHost: addAction('addHost', '.lb-host'),
addTargetContainer: addAction('addTargetContainer', '.lb-target'),
addTargetIp: addAction('addTargetIp', '.lb-target'),
addListener: addAction('addListener', '.lb-listener-source-port'),
-
- selectTab: function(name) {
- this.set('context.tab',name);
- this.$('.tab').removeClass('active');
- this.$('.tab[data-section="'+name+'"]').addClass('active');
- this.$('.section').addClass('hide');
- this.$('.section[data-section="'+name+'"]').removeClass('hide');
- }
},
didInsertElement: function() {
diff --git a/app/loadbalancers/new/view.js b/app/loadbalancers/new/view.js
index 207a7d39c..30ab35ce8 100644
--- a/app/loadbalancers/new/view.js
+++ b/app/loadbalancers/new/view.js
@@ -1,20 +1,13 @@
import Ember from 'ember';
import { addAction } from 'ui/utils/add-view-action';
+import SelectTab from 'ui/mixins/select-tab';
-export default Ember.View.extend({
+export default Ember.View.extend(SelectTab, {
actions: {
addHost: addAction('addHost', '.lb-host'),
addTargetContainer: addAction('addTargetContainer', '.lb-target'),
addTargetIp: addAction('addTargetIp', '.lb-target'),
addListener: addAction('addListener', '.lb-listener-source-port'),
-
- selectTab: function(name) {
- this.set('context.tab',name);
- this.$('.tab').removeClass('active');
- this.$('.tab[data-section="'+name+'"]').addClass('active');
- this.$('.section').addClass('hide');
- this.$('.section[data-section="'+name+'"]').removeClass('hide');
- }
},
didInsertElement: function() {
diff --git a/app/mixins/edit-container.js b/app/mixins/edit-container.js
index f7f6c7ce8..1fa8c312b 100644
--- a/app/mixins/edit-container.js
+++ b/app/mixins/edit-container.js
@@ -472,12 +472,12 @@ export default Ember.Mixin.create(Cattle.NewOrEditMixin, EditHealthCheck, EditLa
portsArray: null,
initPorts: function() {
var out = [];
- var ports = this.get('instance.ports')||[];
- ports.forEach(function(value) {
+ var ports = this.get('ports');
+ if ( ports )
+ {
// Objects, from edit
- if ( typeof value === 'object' )
- {
+ ports.forEach(function(value) {
out.push({
existing: (value.id ? true : false),
obj: value,
@@ -485,22 +485,38 @@ export default Ember.Mixin.create(Cattle.NewOrEditMixin, EditHealthCheck, EditLa
private: value.privatePort,
protocol: value.protocol,
});
- }
- else
- {
- // Strings, from create maybe
- var match = value.match(/^(\d+):(\d+)\/(.*)$/);
- if ( match )
+ });
+ }
+ else
+ {
+ ports = this.get('instance.ports')||[];
+ ports.forEach(function(value) {
+ if ( typeof value === 'object' )
{
+ // Objects, from clone
out.push({
existing: false,
- public: match[1],
- private: match[2],
- protocol: match[3],
+ public: value.publicPort,
+ private: value.privatePort,
+ protocol: value.protocol,
});
}
- }
- });
+ else
+ {
+ // Strings, from create maybe
+ var match = value.match(/^(\d+):(\d+)\/(.*)$/);
+ if ( match )
+ {
+ out.push({
+ existing: false,
+ public: match[1],
+ private: match[2],
+ protocol: match[3],
+ });
+ }
+ }
+ });
+ }
this.set('portsArray', out);
},
diff --git a/app/mixins/edit-loadbalancerconfig.js b/app/mixins/edit-loadbalancerconfig.js
index a419b17f4..a4fea22f5 100644
--- a/app/mixins/edit-loadbalancerconfig.js
+++ b/app/mixins/edit-loadbalancerconfig.js
@@ -27,11 +27,12 @@ export default Ember.Mixin.create(EditHealthCheck,{
listenersArray: null,
initListeners: function() {
var store = this.get('store');
- var existing = this.get('balancer.loadBalancerListeners');
var out = [];
- if ( existing )
+ var existingService = this.get('balancer.loadBalancerListeners');
+ var existingRegular = this.get('listeners');
+ if ( existingService )
{
- existing.forEach((listener) => {
+ existingService.forEach((listener) => {
var neu = listener.cloneForNew();
neu.setProperties({
serviceId: null,
@@ -40,6 +41,10 @@ export default Ember.Mixin.create(EditHealthCheck,{
out.push(neu);
});
}
+ else if ( existingRegular )
+ {
+ out.pushObjects(existingRegular);
+ }
else
{
out.push(store.createRecord({
diff --git a/app/mixins/select-tab.js b/app/mixins/select-tab.js
new file mode 100644
index 000000000..76c3c37aa
--- /dev/null
+++ b/app/mixins/select-tab.js
@@ -0,0 +1,13 @@
+import Ember from 'ember';
+
+export default Ember.Mixin.create({
+ actions: {
+ selectTab: function(name) {
+ this.set('context.tab',name);
+ this.$('.tab').removeClass('active');
+ this.$('.tab[data-section="'+name+'"]').addClass('active');
+ this.$('.section').addClass('hide');
+ this.$('.section[data-section="'+name+'"]').removeClass('hide');
+ }
+ }
+});
diff --git a/app/service/new-balancer/view.js b/app/service/new-balancer/view.js
index 0829715f0..3100cca48 100644
--- a/app/service/new-balancer/view.js
+++ b/app/service/new-balancer/view.js
@@ -1,18 +1,11 @@
import Ember from 'ember';
import { addAction } from 'ui/utils/add-view-action';
+import SelectTab from 'ui/mixins/select-tab';
-export default Ember.View.extend({
+export default Ember.View.extend(SelectTab, {
actions: {
addTargetService: addAction('addTargetService', '.lb-target'),
addListener: addAction('addListener', '.lb-listener-source-port'),
-
- selectTab: function(name) {
- this.set('context.tab',name);
- this.$('.tab').removeClass('active');
- this.$('.tab[data-section="'+name+'"]').addClass('active');
- this.$('.section').addClass('hide');
- this.$('.section[data-section="'+name+'"]').removeClass('hide');
- }
},
didInsertElement: function() {
diff --git a/app/templates/container/edit-ports.hbs b/app/templates/container/edit-ports.hbs
index 5ef202784..0585f09bd 100644
--- a/app/templates/container/edit-ports.hbs
+++ b/app/templates/container/edit-ports.hbs
@@ -25,9 +25,7 @@
{{input class="form-control input-sm port-public" type="number" min="1" max="65535" value=port.public placeholder="e.g. 80"}}
-
+
|
{{port.private}}
diff --git a/app/templates/loadbalancer/config-detail.hbs b/app/templates/loadbalancer/config-detail.hbs
index 283651ad2..d655b634e 100644
--- a/app/templates/loadbalancer/config-detail.hbs
+++ b/app/templates/loadbalancer/config-detail.hbs
@@ -1,7 +1,7 @@
- Listeners ({{listeners.length}})
+ Listeners ({{unremovedListeners.length}})
@@ -16,7 +16,7 @@
- {{#each listener in listeners itemController="loadbalancerlistener"}}
+ {{#each listener in unremovedListeners itemController="loadbalancerlistener"}}
|
@@ -82,13 +82,13 @@
- {{config.healthCheck.healthyThreshold}}ms
+ {{config.healthCheck.healthyThreshold}}
- {{config.healthCheck.unhealthyThreshold}}ms
+ {{config.healthCheck.unhealthyThreshold}}
diff --git a/app/templates/loadbalancer/new-listeners.hbs b/app/templates/loadbalancer/new-listeners.hbs
index 5caba54fa..5970aaa51 100644
--- a/app/templates/loadbalancer/new-listeners.hbs
+++ b/app/templates/loadbalancer/new-listeners.hbs
@@ -14,66 +14,75 @@
{{#each listener in listenersArray}}
- |
-
- |
-
-
|
-
-
- |
+
+
+ |
+ {{/if}}
{{/each}}
| |