mirror of https://github.com/rancher/ui.git
Fix subscribe reconnect (rancher/rancher#3639)
This commit is contained in:
parent
95acd09ca8
commit
6d9c68241f
|
|
@ -81,6 +81,8 @@ export default Ember.Route.extend({
|
||||||
|
|
||||||
activate() {
|
activate() {
|
||||||
this._super();
|
this._super();
|
||||||
|
|
||||||
|
console.log('Activate socket for', this.get(`tab-session.${C.TABSESSION.PROJECT}`));
|
||||||
var store = this.get('store');
|
var store = this.get('store');
|
||||||
var boundTypeify = store._typeify.bind(store);
|
var boundTypeify = store._typeify.bind(store);
|
||||||
|
|
||||||
|
|
@ -95,6 +97,7 @@ export default Ember.Route.extend({
|
||||||
var socket = Socket.create({
|
var socket = Socket.create({
|
||||||
url: url
|
url: url
|
||||||
});
|
});
|
||||||
|
this.set('socket', socket);
|
||||||
|
|
||||||
socket.on('message', (event) => {
|
socket.on('message', (event) => {
|
||||||
var d = JSON.parse(event.data, boundTypeify);
|
var d = JSON.parse(event.data, boundTypeify);
|
||||||
|
|
@ -127,17 +130,28 @@ export default Ember.Route.extend({
|
||||||
this._trySend('subscribeDisconnected', this.get('tries'));
|
this._trySend('subscribeDisconnected', this.get('tries'));
|
||||||
});
|
});
|
||||||
|
|
||||||
this.set('socket', socket);
|
|
||||||
socket.connect();
|
socket.connect();
|
||||||
},
|
},
|
||||||
|
|
||||||
deactivate() {
|
deactivate() {
|
||||||
this._super();
|
this._super();
|
||||||
|
this.closeSocket();
|
||||||
|
},
|
||||||
|
|
||||||
|
resetController() {
|
||||||
|
this._super();
|
||||||
|
this.closeSocket();
|
||||||
|
},
|
||||||
|
|
||||||
|
closeSocket() {
|
||||||
var socket = this.get('socket');
|
var socket = this.get('socket');
|
||||||
if ( socket )
|
if ( socket )
|
||||||
{
|
{
|
||||||
socket.disconnect();
|
socket.disconnect();
|
||||||
|
this.set('socket', null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Ember.run.cancel(this.get('pingTimer'));
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
|
@ -165,6 +179,7 @@ export default Ember.Route.extend({
|
||||||
// WebSocket disconnected
|
// WebSocket disconnected
|
||||||
subscribeDisconnected: function() {
|
subscribeDisconnected: function() {
|
||||||
console.log('Subscribe disconnected');
|
console.log('Subscribe disconnected');
|
||||||
|
this.closeSocket();
|
||||||
},
|
},
|
||||||
|
|
||||||
subscribePing: function() {
|
subscribePing: function() {
|
||||||
|
|
@ -176,7 +191,10 @@ export default Ember.Route.extend({
|
||||||
|
|
||||||
this.set('pingTimer', Ember.run.later(this, function() {
|
this.set('pingTimer', Ember.run.later(this, function() {
|
||||||
console.log('Subscribe missed 2 pings...');
|
console.log('Subscribe missed 2 pings...');
|
||||||
|
if ( this.get('socket') )
|
||||||
|
{
|
||||||
this.get('socket').connect();
|
this.get('socket').connect();
|
||||||
|
}
|
||||||
}, 11000));
|
}, 11000));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -280,10 +298,10 @@ export default Ember.Route.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
k8sResourceChanged: function(changeType, obj) {
|
k8sResourceChanged: function(changeType, obj) {
|
||||||
console.log('k8s change', changeType, (obj && obj.metadata && obj.metadata.uid ? obj.metadata.uid : 'none'));
|
//console.log('k8s change', changeType, (obj && obj.metadata && obj.metadata.uid ? obj.metadata.uid : 'none'));
|
||||||
if ( obj && obj.metadata && obj.metadata.uid && this.get('k8sUidBlacklist').indexOf(obj.metadata.uid) >= 0 )
|
if ( obj && obj.metadata && obj.metadata.uid && this.get('k8sUidBlacklist').indexOf(obj.metadata.uid) >= 0 )
|
||||||
{
|
{
|
||||||
console.log('^-- Ignoring', changeType, 'for removed resource');
|
//console.log('^-- Ignoring', changeType, 'for removed resource');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,7 @@
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if accessEnabled}}
|
||||||
<table class="grid fixed" style="margin-bottom: 0;">
|
<table class="grid fixed" style="margin-bottom: 0;">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
@ -117,6 +118,7 @@
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ export default Ember.Controller.extend({
|
||||||
docsBase: C.EXT_REFERENCES.DOCS,
|
docsBase: C.EXT_REFERENCES.DOCS,
|
||||||
|
|
||||||
thingsChanged: function() {
|
thingsChanged: function() {
|
||||||
console.log(this.get('application.currentRouteName'),this.get('model.hosts.length'),this.get('model.services.length'));
|
//console.log(this.get('application.currentRouteName'),this.get('model.hosts.length'),this.get('model.services.length'));
|
||||||
if ( this.get('application.currentRouteName') === 'splash')
|
if ( this.get('application.currentRouteName') === 'splash')
|
||||||
{
|
{
|
||||||
if ( this.get('model.hosts.length') && this.get('model.services.length') )
|
if ( this.get('model.hosts.length') && this.get('model.services.length') )
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue