Bug fixes

This commit is contained in:
Vincent Fiduccia 2015-04-08 00:28:46 -07:00
parent 969a0a4ff6
commit fd170519ed
10 changed files with 84 additions and 16 deletions

View File

@ -204,6 +204,26 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, {
this._includeChanged('loadBalancer', 'loadBalancerListeners', 'loadBalancerListeners', change.data.resource);
},
loadBalancerChanged: function(change) {
var balancer = change.data.resource;
var config = balancer.get('loadBalancerConfig');
var balancers = config.get('loadBalancers');
if ( !balancers )
{
balancers = [];
config.set('loadBalancers',balancers);
}
if ( config.get('state') === 'removed' )
{
balancers.removeObject(balancer);
}
else
{
balancers.addObject(balancer);
}
},
mountChanged: function(change) {
var mount = change.data.resource;
var volume = this.get('store').getById('volume', mount.get('volumeId'));

View File

@ -2,6 +2,12 @@ import Ember from 'ember';
import Cattle from 'ui/utils/cattle';
var LoadBalancerController = Cattle.TransitioningResourceController.extend({
actions: {
newTarget: function() {
this.transitionToRoute('loadbalancer.targets.new', this.get('id'));
},
},
availableActions: function() {
var a = this.get('actions');

View File

@ -28,10 +28,10 @@
</td>
<td>
{{#if config.appCookieStickinessPolicy}}
Create Cookie
Use existing cookie
{{else}}
{{#if config.lbCookieStickinessPolicy}}
Use existing cookie
Create cookie
{{else}}
None
{{/if}}

View File

@ -5,6 +5,8 @@ var LoadBalancerListener = Cattle.TransitioningResource.extend({
});
LoadBalancerListener.reopenClass({
pollTransitioningDelay: 1000,
pollTransitioningInterval: 5000,
});
export default LoadBalancerListener;

View File

@ -97,6 +97,12 @@ export default Ember.ObjectController.extend(Cattle.NewOrEditMixin, EditLoadBala
});
}.property('targetsArray.@each.{isIp,isContainer,value}'),
activeConfigs: function() {
return this.get('allConfigs').filter((config) => {
return config.get('state') === 'active';
});
}.property('allConfigs.@each.state'),
willSave: function() {
if ( !this._super() )
{

View File

@ -88,7 +88,7 @@
<label>Choose an existing Balancer Configuration</label>
{{view "select"
class="form-control"
content=allConfigs
content=activeConfigs
optionLabelPath="content.name"
optionValuePath="content.id"
value=existingConfigId

View File

@ -23,6 +23,8 @@ var LoadBalancerTarget = Cattle.TransitioningResource.extend({
});
LoadBalancerTarget.reopenClass({
pollTransitioningDelay: 1000,
pollTransitioningInterval: 5000,
});
export default LoadBalancerTarget;

View File

@ -148,40 +148,66 @@ var TransitioningResource = Resource.extend({
isError: Ember.computed.equal('transitioning','error'),
replaceWith: function() {
//console.log('1 replaceWith', this.get('id'));
this._super.apply(this,arguments);
this.transitioningChanged();
},
wasAdded: function() {
this.transitioningChanged();
},
wasRemoved: function() {
this.transitioningChanged();
},
pollDelayTimer: null,
pollTimer: null,
reservedKeys: ['pollDelayTimer','pollTimer','waitInterval','waitTimeout'],
transitioningChanged: function() {
//console.log('Transitioning changed', this.toString(), this.get('transitioning'), this.get('pollDelayTimer'),this.get('pollTimer'));
//console.log('Transitioning changed', this.toString(), this.get('transitioning'), this.get('pollDelayTimer'), this.get('pollTimer'));
clearTimeout(this.get('pollDelayTimer'));
clearTimeout(this.get('pollTimer'));
if ( !this.isInStore() )
if ( this.get('transitioning') !== 'yes' || !this.isInStore() )
{
//console.log('This resource is not in the store');
clearTimeout(this.get('pollDelayTimer'));
clearTimeout(this.get('pollTimer'));
return;
}
if ( this.get('pollDelayTimer') )
{
// Already polling or waiting, just let that one finish
return;
}
var delay = this.constructor.pollTransitioningDelay;
var interval = this.constructor.pollTransitioningInterval;
if ( delay > 0 && interval > 0 && this.get('transitioning') === 'yes' )
{
//console.log('Starting poll timer', this.toString());
this.set('pollDelayTimer', setTimeout(function() {
//console.log('1 expired');
//console.log('1 expired', this.toString());
this.transitioningPoll();
}.bind(this), delay));
}
else
{
//console.log('Not polling', this.toString());
clearTimeout(this.get('pollDelayTimer'));
this.set('pollDelayTimer', null);
}
}.observes('transitioning'),
transitioningPoll: function() {
clearTimeout(this.get('pollTimer'));
var self = this;
function reset() {
clearTimeout(self.get('pollDelayTimer'));
self.set('pollDelayTimer',null);
}
clearTimeout(this.get('pollTimer'));
this.set('pollTimer',null);
//console.log('Checking', this.toString());
if ( this.get('transitioning') !== 'yes' || !this.isInStore() )
@ -196,10 +222,16 @@ var TransitioningResource = Resource.extend({
{
//console.log('Rescheduling', this.toString());
this.set('pollTimer', setTimeout(function() {
//console.log('2 expired');
//console.log('2 expired', this.toString());
this.transitioningPoll();
}.bind(this), this.constructor.pollTransitioningInterval));
}
else
{
reset();
}
}).catch(() => {
reset();
});
},
@ -241,7 +273,7 @@ var TransitioningResource = Resource.extend({
waitForAction: function(name) {
return this._waitForTestFn(function() {
console.log('waitForAction('+name+'):', this.hasAction(name));
//console.log('waitForAction('+name+'):', this.hasAction(name));
return this.hasAction(name);
}, 'Wait for action='+name);
},

View File

@ -9,11 +9,11 @@ export default Overlay.extend({
actions: {
overlayClose: function() {
this.get('controller').send('cancel');
this.get('controller').send('cancelDelete');
},
overlayEnter: function() {
this.get('controller').send('confirm');
this.get('controller').send('confirmDelete');
}
}
});

View File

@ -24,7 +24,7 @@
"broccoli-asset-rev": "^2.0.0",
"broccoli-sass": "0.6.2",
"connect-restreamer": "^1.0.1",
"ember-api-store": "1.0.14",
"ember-api-store": "1.0.15",
"ember-browserify": "^0.6.4",
"ember-cli": "0.2.0",
"ember-cli-app-version": "0.3.3",