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() {
|
||||
this._super();
|
||||
|
||||
console.log('Activate socket for', this.get(`tab-session.${C.TABSESSION.PROJECT}`));
|
||||
var store = this.get('store');
|
||||
var boundTypeify = store._typeify.bind(store);
|
||||
|
||||
|
|
@ -95,6 +97,7 @@ export default Ember.Route.extend({
|
|||
var socket = Socket.create({
|
||||
url: url
|
||||
});
|
||||
this.set('socket', socket);
|
||||
|
||||
socket.on('message', (event) => {
|
||||
var d = JSON.parse(event.data, boundTypeify);
|
||||
|
|
@ -127,17 +130,28 @@ export default Ember.Route.extend({
|
|||
this._trySend('subscribeDisconnected', this.get('tries'));
|
||||
});
|
||||
|
||||
this.set('socket', socket);
|
||||
socket.connect();
|
||||
},
|
||||
|
||||
deactivate() {
|
||||
this._super();
|
||||
this.closeSocket();
|
||||
},
|
||||
|
||||
resetController() {
|
||||
this._super();
|
||||
this.closeSocket();
|
||||
},
|
||||
|
||||
closeSocket() {
|
||||
var socket = this.get('socket');
|
||||
if ( socket )
|
||||
{
|
||||
socket.disconnect();
|
||||
this.set('socket', null);
|
||||
}
|
||||
|
||||
Ember.run.cancel(this.get('pingTimer'));
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
|
@ -165,6 +179,7 @@ export default Ember.Route.extend({
|
|||
// WebSocket disconnected
|
||||
subscribeDisconnected: function() {
|
||||
console.log('Subscribe disconnected');
|
||||
this.closeSocket();
|
||||
},
|
||||
|
||||
subscribePing: function() {
|
||||
|
|
@ -176,7 +191,10 @@ export default Ember.Route.extend({
|
|||
|
||||
this.set('pingTimer', Ember.run.later(this, function() {
|
||||
console.log('Subscribe missed 2 pings...');
|
||||
this.get('socket').connect();
|
||||
if ( this.get('socket') )
|
||||
{
|
||||
this.get('socket').connect();
|
||||
}
|
||||
}, 11000));
|
||||
},
|
||||
|
||||
|
|
@ -280,10 +298,10 @@ export default Ember.Route.extend({
|
|||
},
|
||||
|
||||
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 )
|
||||
{
|
||||
console.log('^-- Ignoring', changeType, 'for removed resource');
|
||||
//console.log('^-- Ignoring', changeType, 'for removed resource');
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -71,52 +71,54 @@
|
|||
</div>
|
||||
{{/if}}
|
||||
|
||||
<table class="grid fixed" style="margin-bottom: 0;">
|
||||
<thead>
|
||||
<tr>
|
||||
{{sortable-th sortable=this action="changeSort" name="name"}}
|
||||
{{sortable-th sortable=this action="changeSort" name="type"}}
|
||||
{{sortable-th sortable=this action="changeSort" name="role"}}
|
||||
{{#if showEdit}}<th width="40"> </th>{{/if}}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each arranged as |member|}}
|
||||
{{#if accessEnabled}}
|
||||
<table class="grid fixed" style="margin-bottom: 0;">
|
||||
<thead>
|
||||
<tr>
|
||||
<td>
|
||||
{{identity-block identity=member}}
|
||||
</td>
|
||||
<td>{{member.displayType}}</td>
|
||||
<td>
|
||||
{{#if showEdit}}
|
||||
<select class="form-control input-sm" onchange={{action (mut member.role) value="target.value"}}>
|
||||
{{#each roleOptions as |choice|}}
|
||||
<option value={{choice.value}} selected={{eq member.role choice.value}}>{{choice.label}}</option>
|
||||
{{/each}}
|
||||
</select>
|
||||
{{else}}
|
||||
{{uc-first member.role}}
|
||||
{{/if}}
|
||||
</td>
|
||||
{{#if showEdit}}
|
||||
{{sortable-th sortable=this action="changeSort" name="name"}}
|
||||
{{sortable-th sortable=this action="changeSort" name="type"}}
|
||||
{{sortable-th sortable=this action="changeSort" name="role"}}
|
||||
{{#if showEdit}}<th width="40"> </th>{{/if}}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each arranged as |member|}}
|
||||
<tr>
|
||||
<td>
|
||||
{{#if accessEnabled}}
|
||||
<button class="btn-circle btn-sm pull-right gh-action" {{action "removeMember" member}}><i class="icon icon-x-circle"/></button>
|
||||
{{identity-block identity=member}}
|
||||
</td>
|
||||
<td>{{member.displayType}}</td>
|
||||
<td>
|
||||
{{#if showEdit}}
|
||||
<select class="form-control input-sm" onchange={{action (mut member.role) value="target.value"}}>
|
||||
{{#each roleOptions as |choice|}}
|
||||
<option value={{choice.value}} selected={{eq member.role choice.value}}>{{choice.label}}</option>
|
||||
{{/each}}
|
||||
</select>
|
||||
{{else}}
|
||||
|
||||
{{uc-first member.role}}
|
||||
{{/if}}
|
||||
</td>
|
||||
{{/if}}
|
||||
</tr>
|
||||
{{else}}
|
||||
<tr>
|
||||
<td colspan="3" class="text-center text-muted">
|
||||
{{if showEdit 'No members yet, add at least one owner.' 'This project has no members.'}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{#if showEdit}}
|
||||
<td>
|
||||
{{#if accessEnabled}}
|
||||
<button class="btn-circle btn-sm pull-right gh-action" {{action "removeMember" member}}><i class="icon icon-x-circle"/></button>
|
||||
{{else}}
|
||||
|
||||
{{/if}}
|
||||
</td>
|
||||
{{/if}}
|
||||
</tr>
|
||||
{{else}}
|
||||
<tr>
|
||||
<td colspan="3" class="text-center text-muted">
|
||||
{{if showEdit 'No members yet, add at least one owner.' 'This project has no members.'}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{/if}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ export default Ember.Controller.extend({
|
|||
docsBase: C.EXT_REFERENCES.DOCS,
|
||||
|
||||
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('model.hosts.length') && this.get('model.services.length') )
|
||||
|
|
|
|||
Loading…
Reference in New Issue