show the connection manager when the ui disconnects

This commit is contained in:
Damien Churchill 2010-03-14 10:00:04 +00:00
parent 2952a5a7a3
commit e83737805d
1 changed files with 20 additions and 1 deletions

View File

@ -162,6 +162,8 @@ Copyright:
Ext.deluge.ConnectionManager.superclass.initComponent.call(this); Ext.deluge.ConnectionManager.superclass.initComponent.call(this);
this.on('hide', this.onHide, this); this.on('hide', this.onHide, this);
this.on('show', this.onShow, this); this.on('show', this.onShow, this);
Deluge.Events.on('disconnect', this.onDisconnect, this);
Deluge.Events.on('login', this.onLogin, this); Deluge.Events.on('login', this.onLogin, this);
Deluge.Events.on('logout', this.onLogout, this); Deluge.Events.on('logout', this.onLogout, this);
@ -326,11 +328,13 @@ Copyright:
this.loadHosts(); this.loadHosts();
}, },
// private
onClose: function(e) { onClose: function(e) {
if (this.running) window.clearInterval(this.running); if (this.running) window.clearInterval(this.running);
this.hide(); this.hide();
}, },
// private
onConnect: function(e) { onConnect: function(e) {
var selected = this.grid.getSelectionModel().getSelected(); var selected = this.grid.getSelectionModel().getSelected();
if (!selected) return; if (!selected) return;
@ -357,6 +361,12 @@ Copyright:
} }
}, },
onDisconnect: function() {
if (this.isVisible()) return;
this.show();
},
// private
onGetHosts: function(hosts) { onGetHosts: function(hosts) {
this.grid.getStore().loadData(hosts); this.grid.getStore().loadData(hosts);
Ext.each(hosts, function(host) { Ext.each(hosts, function(host) {
@ -367,6 +377,7 @@ Copyright:
}, this); }, this);
}, },
// private
onGetHostStatus: function(host) { onGetHostStatus: function(host) {
var record = this.grid.getStore().getById(host[0]); var record = this.grid.getStore().getById(host[0]);
record.set('status', host[3]) record.set('status', host[3])
@ -375,10 +386,12 @@ Copyright:
if (this.grid.getSelectionModel().getSelected() == record) this.updateButtons(record); if (this.grid.getSelectionModel().getSelected() == record) this.updateButtons(record);
}, },
// private
onHide: function() { onHide: function() {
if (this.running) window.clearInterval(this.running); if (this.running) window.clearInterval(this.running);
}, },
// private
onLogin: function() { onLogin: function() {
if (Deluge.config.first_login) { if (Deluge.config.first_login) {
Ext.MessageBox.confirm('Change password', Ext.MessageBox.confirm('Change password',
@ -397,6 +410,7 @@ Copyright:
} }
}, },
// private
onLogout: function() { onLogout: function() {
this.disconnect(); this.disconnect();
if (!this.hidden && this.rendered) { if (!this.hidden && this.rendered) {
@ -404,6 +418,7 @@ Copyright:
} }
}, },
// private
onRemove: function(button) { onRemove: function(button) {
var connection = this.grid.getSelectionModel().getSelected(); var connection = this.grid.getSelectionModel().getSelected();
if (!connection) return; if (!connection) return;
@ -427,10 +442,12 @@ Copyright:
}); });
}, },
// private
onSelect: function(selModel, rowIndex, record) { onSelect: function(selModel, rowIndex, record) {
this.selectedRow = rowIndex; this.selectedRow = rowIndex;
}, },
// private
onSelectionChanged: function(selModel) { onSelectionChanged: function(selModel) {
var record = selModel.getSelected(); var record = selModel.getSelected();
if (selModel.hasSelection()) { if (selModel.hasSelection()) {
@ -444,6 +461,7 @@ Copyright:
this.updateButtons(record); this.updateButtons(record);
}, },
// private
onShow: function() { onShow: function() {
if (!this.addHostButton) { if (!this.addHostButton) {
var bbar = this.grid.getBottomToolbar(); var bbar = this.grid.getBottomToolbar();
@ -454,7 +472,8 @@ Copyright:
this.loadHosts(); this.loadHosts();
this.running = window.setInterval(this.update, 2000, this); this.running = window.setInterval(this.update, 2000, this);
}, },
// private
onStop: function(button, e) { onStop: function(button, e) {
var connection = this.grid.getSelectionModel().getSelected(); var connection = this.grid.getSelectionModel().getSelected();
if (!connection) return; if (!connection) return;